5 ##---------------------------------------------------------------------------##
8 ## Markus F.X.J. Oberhumer <markus@oberhumer.com>
11 ## Convert the output of the LZO lzotest program into a nice table.
13 ## Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
15 ##---------------------------------------------------------------------------##
24 while ($_ = $ARGV[ $[ ], /^-/) {
26 /^--$/ && ($opt_last = 1, last);
28 /^--sort=name/ && ($opt_sort_summary_by_name++, next);
29 /^--sort=ratio/ && ($opt_sort_summary_by_ratio++, next);
30 /^-s/ && ($opt_summary_only++, next);
31 /^-t/ && ($opt_clear_time++, next);
36 $sep = "+" . ("-" x
76) . "+\n";
45 $lzo_version_string = '';
46 $lzo_version_date = '';
49 # /***********************************************************************
51 # ************************************************************************/
55 if (/(^|\s)(\d+)\s+block\-size/i) {
56 if ($block_size < 0) {
59 } elsif ($block_size != $2) {
60 die "$PROG: block-size: $block_size != $2\n";
65 if (/^\s*LZO\s.*library\s+\(v\s*([\w\.\s]+)\s*\,\s*([^\)]+)\)/) {
66 $lzo_version_string = $1;
67 $lzo_version_date = $2;
71 if (/^\s*(\S+(\s+\[\S+\])?)\s*(\|.*\|)\s*$/i) {
78 print "$line\n" if (!$opt_summary_only);
88 # /***********************************************************************
90 # ************************************************************************/
94 local ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8);
96 if ($l !~ /^\|\s*(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\.]+\s+)?([\d\.]+\s+)?([\d\.]+)\s+([\d\.]+)\s*\|/) {
102 $x1 = $1; $x2 = $2; $x3 = $3; $x4 = $4;
103 $x5 = ($x2 > 0) ?
$x4 * 100.0 / $x2 : 0.0;
104 $x6 = ($x2 > 0) ?
$x4 * 8.0 / $x2 : 0.0;
107 # convert from kB/s to MB/s (for old versions of lzotest)
108 if ($x7 =~ /\.\d\d$/) { $x7 = $x7 / 1000.0; }
109 if ($x8 =~ /\.\d\d$/) { $x8 = $x8 / 1000.0; }
111 if ($opt_clear_time) {
121 $s[5] += 1.0 / $x7; $sn[5] += 1;
124 $s[6] += 1.0/ $x8; $sn[6] += 1;
128 $l = sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |",
129 $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8);
133 # /***********************************************************************
135 # ************************************************************************/
144 @s = (0, 0, 0, 0.0, 0.0, 0.0, 0.0);
145 @sn = (0, 0, 0, 0, 0, 0, 0);
147 return if $opt_summary_only;
152 | File Name Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
153 | --------- ------ --- ------ ----- ---- -------- -------- |
158 # /***********************************************************************
160 # ************************************************************************/
164 local ($shm5, $shm6);
171 $shm5 = $s[5] > 0 ?
$sn[5] / $s[5] : 0.0;
172 $shm6 = $s[6] > 0 ?
$sn[6] / $s[6] : 0.0;
177 sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |\n",
178 "Average", $s[0]/$n, $s[1]/$n, $s[2]/$n,
183 sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |\n",
184 "Total", $s[0], $s[1], $s[2],
185 $s[2]/$s[0]*100, $s[2]/$s[0]*8,
188 return if $opt_summary_only;
191 print $average{$alg};
197 # /***********************************************************************
199 # ************************************************************************/
206 if ($sort_mode == 0) {
209 } elsif ($sort_mode == 1) {
216 ($aa =~ m
%^\s
*\
|\s
+\S
+\s
+\d
+\s
+\d
+\s
+\d
+\s
+(\S
+)%) || die;
218 ($bb =~ m
%^\s
*\
|\s
+\S
+\s
+\d
+\s
+\d
+\s
+\d
+\s
+(\S
+)%) || die;
226 # /***********************************************************************
228 # ************************************************************************/
235 if ($opt_sort_summary_by_name) {
237 } elsif ($opt_sort_summary_by_ratio) {
238 @k = sort(cmp_by_ratio
@algs);
244 print "Summary of average values\n\n";
247 | Algorithm Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
248 | --------- ------ --- ------ ----- ---- -------- -------- |
253 $l =~ s/Average[\s]{7}/sprintf("%-14s",$_)/e;
261 if ($opt_sort_summary_by_name) {
263 } elsif ($opt_sort_summary_by_ratio) {
264 @k = sort(cmp_by_ratio
@algs);
270 print "Summary of total values\n\n";
273 | Algorithm Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
274 | --------- ------ --- ------ ----- ---- -------- -------- |
279 $l =~ s/Total[\s]{9}/sprintf("%-14s",$_)/e;
286 # /***********************************************************************
288 # ************************************************************************/
293 local ($u, $uname_m, $uname_s, $uname_r);
295 $t = &ctime
(time); chop($t);
296 $t = sprintf("%-55s |", $t);
299 if ($lzo_version_string) {
300 $v = $lzo_version_string;
301 $v .= ', ' . $lzo_version_date if $lzo_version_date;
302 $v = sprintf("%-55s |", $v);
303 $v = sprintf("| LZO version : %s\n", $v);
306 if ($bs % 1024 == 0) {
307 $x = sprintf("%d (= %d kB)", $bs, $bs / 1024);
309 $x = sprintf("%d (= %.3f kB)", $bs, $bs / 1024.0);
311 $x = sprintf("%-55s |", $x);
315 $uname_s = `uname -s`; $uname_s =~ s/^\s+//; $uname_s =~ s/\s+$//;
316 $uname_r = `uname -r`; $uname_r =~ s/^\s+//; $uname_r =~ s/\s+$//;
317 $uname_m = `uname -m`; $uname_m =~ s/^\s+//; $uname_m =~ s/\s+$//;
318 if ($uname_s && $uname_m) {
320 $u .= ' ' . $uname_r if $uname_r;
321 $u .= ' ' . $uname_m;
322 $u = sprintf("%-55s |", $u);
323 $u = sprintf("| Operating system : %s\n", $u);
328 +----------------------------------------------------------------------------+
329 | DATA COMPRESSION TEST |
330 | ===================== |
332 $v$u| Context length : $x
333 +----------------------------------------------------------------------------+
337 - CxB is the number of independent blocks a file was splitted
338 - MB/s is the speed measured in 1,000,000 uncompressed bytes per second
339 - all averages are calculated from the un-rounded values
340 - the average ratio & bits are calculated by the arithmetic mean
341 - the average speed is calculated by the harmonic mean
350 ### insert something like this after 'Time of run':
352 | Hardware
: Intel Pentium
133, 64 MB RAM
, 256 kB Cache
|
353 | Operating
system : MS
-DOS
7.10, HIMEM
.SYS
3.95, DOS
/4GW
1.97 |
354 | Compiler
: Watcom C32
10.5 |
355 | Compiler flags
: -mf
-5r
-oneatx
|
356 | Test suite
: Calgary Corpus Suite
|
357 | Files
in suite
: 14 |
358 | Timing accuracy
: One part
in 100 |