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 48 49 50 51 52 53 54 55 56 57 58
|
#!/usr/bin/env perl
#
# Copyright (c) 2015, Jyri J. Virkki
# All rights reserved.
#
# This file is under BSD license. See LICENSE file.
#
#
# ./colgraph SIZE ERROR
#
# SIZE = size of bloom library to initialize
# ERROR = expected error
#
# This script runs a random collision test (test-libbloom -c) $rounds
# number of times for 10 element counts from SIZE/10 to SIZE. The
# average of each run is saved in the 'data' file in the current
# directory.
#
# If ploticus is available it'll also display a graph. Or you can use
# any other graphing app or tool to process the 'data' file.
#
$rounds = 25;
$size = shift(@ARGV);
if (!$size) {
die "provide a size\n";
}
$error = shift(@ARGV);
if (!$error) {
die "provide expected error\n";
}
open(OUT, ">data");
for ($tenth = 1; $tenth < 11; $tenth++) {
$count = ($size / 10) * $tenth;
$avg = 0;
for ($n = 0; $n < $rounds; $n++) {
open(RES, "../build/test-libbloom -c $size $error $count |");
while(<RES>) {$got = $_;}
close(RES);
($added, $coll) = $got =~ /count: (\d+), coll: (\d+)/;
$avg += $coll;
}
$avg /= $rounds;
print "ADDED $added, AVG.COLL $avg\n";
print OUT "$added, $avg\n";
}
close(OUT);
$cmd = "ploticus -prefab lines data=data x=1 y=2 \"xrange=0 $size\" " .
"\"title=size = $size\" \"ylbl=collisions\" \"xlbl=count\" ";
print "$cmd\n";
system($cmd);
|