Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature qw/say/;
- use Text::Diff;
- sub checkLimit {
- my ($aref,$limit,$res) = @_;
- for (@$aref) {
- if ($_ > $limit) {
- push @$res, $_;
- };
- }
- }
- my @a = ();
- # fill
- for(my $c=0 ; $c < 100000 ; $c++){
- $a[$c] = rand();
- #if (($c % 10000)==0) {
- # print $c . "\n";
- #}
- }
- my @res;
- for my $i (1..100) {
- my $pmap_before = `pmap $$`;
- # check
- foreach my $limit (map { 0.01 * $_ } 1..100 ) {
- checkLimit(\@a, $limit, \@res);
- #printf("limit %0.3f count %d\n",$limit, scalar @res );
- @res = ();
- }
- my $pmap_after = `pmap $$`;
- my $diff = diff \$pmap_before, \$pmap_after;
- if ($diff) {
- say "memory usage changed in iteration $i";
- say $diff;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment