/
demo.pl
executable file
·48 lines (36 loc) · 1022 Bytes
/
demo.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
use warnings;
use strict;
use List::Util 'shuffle';
open WORDS, "/usr/share/dict/words" or die $!;
open PATCH, ">patch" or die $!;
my $count = 0;
my @words;
while (<WORDS>) {
chomp $_;
print PATCH "+" . length($_) . "," . length($_) . ":" . $_ . "->" . $_ . "\n";
$count += 1;
push(@words, $_);
}
close(PATCH);
open QUERY, ">query" or die $!;
for (my $queries = 0; $queries < 1000000; $queries++)
{
my $word = $words[ rand($#words) ] ;
print QUERY length($word) . ":$word\n";
}
close(QUERY);
open PREFIX, ">prefix" or die $!;
for (my $queries = 0; $queries < 1000000; $queries++)
{
my $word = $words[ rand($#words) ] ;
print PREFIX (length($word) + 1) . ":$word" . "x\n";
}
close(PREFIX);
unlink("dict.db");
# Create the dict db
print "Creating DB file with $count records\n";
system("time ./nutrient_patch patch dict.db");
# Query the DN
print "Querying the DB file for 10,000,000 random records\n";
system("time ./nutrient_query query dict.db > /dev/null");