Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2KB

  1. #!/usr/bin/perl
  2. use strict;
  3. use FindBin;
  4. sub usage {
  5. print "usage: keystats [-v] keyfile\n";
  6. print "usage: keystats [-p <pct> [-v]] keyfile\n";
  7. exit -1;
  8. }
  9. usage if ((@ARGV == 0) or ($ARGV[0] eq '-h'));
  10. my @exes = glob "'$FindBin::Bin/keystat.???'";
  11. my %stats;
  12. for my $exe (@exes) {
  13. $exe =~ s/\ /\\ /g;
  14. $stats{$exe} = `$exe @ARGV`;
  15. delete $stats{$exe} if ($? != 0); # omit hash functions that fail to produce stats (nx)
  16. }
  17. print( "fcn ideal% #items #buckets dup% fl add_usec find_usec del-all usec\n");
  18. printf("--- ------ ---------- ---------- ----- -- ---------- ---------- ------------\n");
  19. for my $exe (sort statsort keys %stats) {
  20. my ($ideal,$items,$bkts,$dups,$ok,$add,$find,$del) = split /,/, $stats{$exe};
  21. # convert 0-1 values to percentages
  22. $dups = $items ? (100.0 * $dups / $items) : 0.0;
  23. $ideal = 100.0 * $ideal;
  24. printf("%3s %5.1f%% %10d %10d %4.0f%% %2s %10d %10d %12d\n", substr($exe,-3,3),
  25. $ideal,$items,$bkts,$dups,$ok,$add,$find,$del);
  26. }
  27. # sort on hash_q (desc) then by find_usec (asc)
  28. sub statsort {
  29. my @a_stats = split /,/, $stats{$a};
  30. my @b_stats = split /,/, $stats{$b};
  31. return ($b_stats[0] <=> $a_stats[0]) || ($a_stats[-1] <=> $b_stats[-1]);
  32. }