Skip to content

Instantly share code, notes, and snippets.

@gray
Created July 7, 2010 19:45
Show Gist options
  • Save gray/467168 to your computer and use it in GitHub Desktop.
Save gray/467168 to your computer and use it in GitHub Desktop.
Benchmark process size
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
use GTop;
use Proc::ProcessTable;
my $gtop = GTop->new;
my $ptable = Proc::ProcessTable->new(cache_ttys => 1);
cmpthese -1, {
gtop => sub {
$gtop->proc_mem($$)->size;
},
gtop_renew => sub {
GTop->new->proc_mem($$)->size;
},
ptable => sub {
for (@{$ptable->table}) {
return $_->size if $$ == $_->pid;
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment