Guest User

Untitled

a guest
Aug 4th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.88 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. #use Term::ReadKey;
  5.  
  6. sub checkLimit($$$){
  7.     my ($p_a, $p_limit, $p_res) = @_;
  8.     foreach (@{$p_a}) {
  9.         push(@{$p_res}, $_) if $_ > $p_limit;
  10.     }
  11. }
  12.  
  13. my @a;
  14. for ( my $c = 0; $c < 100000; $c++ ) {
  15.     $a[$c] = rand();
  16.     print "$c " unless $c % 1000;
  17.     print "\n" unless $c % 10000;
  18. }
  19. print "\n";
  20. printf("Data filled %s, check the memory. ex.: memstat -w -p %s\n",$#a,$$);
  21. system("memstat -w -p $$");
  22.  
  23. print "Start dta check\n";
  24.  
  25. for ( my $x = 0; $x < 6; $x++ ){
  26.     print "round: $x\n\n";
  27.  
  28.     my $limit;
  29.     my @res;
  30.     foreach $limit ( map { 0.01 * $_ } 1..100 ) {
  31.         checkLimit(\@a, \$limit, \@res);
  32.         # printf ("limit %0.3f count %d\n", $limit, $#res);
  33.         @res = ();
  34.     }
  35.  
  36.     #undef @res;
  37.  
  38.     printf("Pls check again the memory usage. ex.: memstat -w -p %s\n",$$);
  39.     system("memstat -w -p $$");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment