/usr/lib/perl5/memsize.pl is in libtokyocabinet-perl 1.34-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #! /usr/bin/perl
use lib qw(./blib/lib ./blib/arch);
use strict;
use warnings;
use TokyoCabinet;
use Time::HiRes qw(gettimeofday);
sub memoryusage {
my $status = `cat /proc/$$/status`;
my @lines = split("\n", $status);
foreach my $line (@lines){
if($line =~ /^VmRSS:/){
$line =~ s/.*:\s*(\d+).*/$1/;
return int($line) / 1024.0;
}
}
return -1;
}
my $rnum = 1000000;
if(scalar(@ARGV) > 0){
$rnum = int($ARGV[0]);
}
my %hash;
if(scalar(@ARGV) > 1){
tie(%hash, "TokyoCabinet::ADB", $ARGV[1]) || die("tie failed");
}
my $stime = gettimeofday();
for(my $i = 0; $i < $rnum; $i++){
my $buf = sprintf("%08d", $i);
$hash{$buf} = $buf;
}
my $etime = gettimeofday();
printf("Time: %.3f sec.\n", $etime - $stime);
printf("Usage: %.3f MB\n", memoryusage());
|