Guest User

Untitled

a guest
Aug 4th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.73 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use feature qw/say/;
  6. use Text::Diff;
  7.  
  8. sub checkLimit {
  9.     my ($aref,$limit,$res) = @_;
  10.  
  11.     for (@$aref) {
  12.         if ($_ > $limit) {
  13.             push @$res, $_;
  14.         };
  15.     }
  16. }
  17.  
  18. my @a = ();
  19.  
  20. # fill
  21. for(my $c=0 ; $c < 100000 ; $c++){
  22.     $a[$c] = rand();
  23.     #if (($c % 10000)==0) {
  24.     #   print $c . "\n";
  25.     #}
  26. }
  27.  
  28. my @res;
  29. for my $i (1..100) {
  30.     my $pmap_before = `pmap $$`;
  31.  
  32.     # check
  33.     foreach my $limit (map { 0.01 * $_ } 1..100 ) {
  34.         checkLimit(\@a, $limit, \@res);
  35.         #printf("limit %0.3f count %d\n",$limit, scalar @res );
  36.         @res = ();
  37.     }
  38.  
  39.     my $pmap_after = `pmap $$`;
  40.     my $diff = diff \$pmap_before, \$pmap_after;
  41.    
  42.     if ($diff) {
  43.         say "memory usage changed in iteration $i";
  44.         say $diff;
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment