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.

29 lines
812B

  1. #!/usr/bin/perl
  2. # This program generates a simkey10.dat (100, 1000, etc) each
  3. # containing 100 random keys of length 10 (100, 1000, etc).
  4. # These files can then be fed into keystats to observe that
  5. # the time to add or find the keys is directly proportional to
  6. # keylength n [in other words, O(n)].
  7. #
  8. # The conclusion is that really long keys (e.g. 100k) are not
  9. # efficient. TDH 23Jan07
  10. use strict;
  11. use warnings;
  12. #for my $len (10,100,1000,10000,100000,1000000) {
  13. for my $len (100) {
  14. open OUTFILE, ">simkeys$len.dat" or die "can't open: $!\n";
  15. # we'll do 100 keys of $len
  16. print "keylen $len\n";
  17. for my $i (0..99) {
  18. my $key = pack "I", $len;
  19. $key .= pack "C", (int(rand(256))) for (1..$len);
  20. print OUTFILE $key;
  21. }
  22. close OUTFILE;
  23. }