Repository navigation
Expand file tree
/
Copy pathcolcmp
More file actions
executable file
·99 lines (81 loc) · 2.1 KB
/
Copy pathcolcmp
File metadata and controls
executable file
·99 lines (81 loc) · 2.1 KB
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
<
9F2C
div data-line-number="54" class="react-line-number react-code-text" style="padding-right:16px">5455
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env perl
#
# Copyright (c) 2015, Jyri J. Virkki
# All rights reserved.
#
# This file is under BSD license. See LICENSE file.
#
#
# ./colcmp FILE1 [FILEn*]
#
# Graph one or more collision average runs (generated with colgraph).
# The runs must be for the same SIZE (see colgraph).
#
# Requires ploticus to generate the graph. Note that the lines prefab
# only supports four data sets so in practice that is the limit,
# even though this script will process any number of input file.
#
# (To plot more than four, you could load the generated 'data.cmp'
# file into an alternate graphing tool or spreadsheet instead of
# relying on ploticus.)
#
$sets = 0;
while (@ARGV) {
$files[$sets] = shift(@ARGV);
if (! -e $files[$sets]) {
die "$files[$sets] does not exist!\n";
}
$sets++;
}
if ($sets < 1) {
die "Need at least some data!\n";
}
for ($n = 0; $n < $sets; $n++) {
local *FILE;
open(FILE, $files[$n]);
$fh[$n] = *FILE;
}
open(OUT, ">data.cmp");
# Read one line at a time from each input file.
# All files must be comparable, meaning the count column
# for each line must be the same, else give up.
$points = 0;
while(readline $fh[0]) {
chomp;
($count, $avg[0]) = /(\d+), (\S+)/;
for ($n = 1; $n < $sets; $n++) {
$_ = readline $fh[$n]; chomp;
($nc, $avg[$n]) = /(\d+), (\S+)/;
if ($nc ne $count) {
die "Mismatch in file $files[$n]: $nc instead of $count\n";
}
}
print OUT $count;
for ($n = 0; $n < $sets; $n++) {
print OUT " $avg[$n]";
}
print OUT "\n";
$points++;
}
# Close all files...
for ($n = 0; $n < $sets; $n++) {
close($fh[$n]);
}
close(OUT);
if (!$points) {
die "Nothing to show!\n";
}
$cmd = "ploticus -prefab lines data=data.cmp " .
" \"xrange=0 $count\" " .
" \"title=size = $count\" " .
"\"ylbl=collisions\" \"xlbl=count\" " .
"x=1 y=2 ";
for ($n = 1; $n < $sets; $n++) {
$cmd .= " y" . ($n+1) . "=" . ($n+2);
}
$cmd .= " \"name=$files[0]\" ";
for ($n = 1; $n < $sets; $n++) {
$cmd .= " \"name" . ($n+1) . "=$files[$n]\" ";
}
print "$cmd\n";
system($cmd);