|
kusano |
7d535a |
#! /usr/bin/perl
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
## vi:ts=4:et
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
##---------------------------------------------------------------------------##
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
## Author:
|
|
kusano |
7d535a |
## Markus F.X.J. Oberhumer <markus@oberhumer.com></markus@oberhumer.com>
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
## Description:
|
|
kusano |
7d535a |
## Convert the output of the LZO lzotest program into a nice table.
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
## Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
##
|
|
kusano |
7d535a |
##---------------------------------------------------------------------------##
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$PROG = $0;
|
|
kusano |
7d535a |
require 'ctime.pl';
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#
|
|
kusano |
7d535a |
# get options
|
|
kusano |
7d535a |
#
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
while ($_ = $ARGV[ $[ ], /^-/) {
|
|
kusano |
7d535a |
shift(@ARGV);
|
|
kusano |
7d535a |
/^--$/ && ($opt_last = 1, last);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/^--sort=name/ && ($opt_sort_summary_by_name++, next);
|
|
kusano |
7d535a |
/^--sort=ratio/ && ($opt_sort_summary_by_ratio++, next);
|
|
kusano |
7d535a |
/^-s/ && ($opt_summary_only++, next);
|
|
kusano |
7d535a |
/^-t/ && ($opt_clear_time++, next);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$alg = '';
|
|
kusano |
7d535a |
$sep = "+" . ("-" x 76) . "+\n";
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$block_size = -1;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$n = 0;
|
|
kusano |
7d535a |
@algs = ();
|
|
kusano |
7d535a |
%average = ();
|
|
kusano |
7d535a |
%total = ();
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$lzo_version_string = '';
|
|
kusano |
7d535a |
$lzo_version_date = '';
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
while (<>) {
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if (/(^|\s)(\d+)\s+block\-size/i) {
|
|
kusano |
7d535a |
if ($block_size < 0) {
|
|
kusano |
7d535a |
$block_size = $2;
|
|
kusano |
7d535a |
&intro($block_size);
|
|
kusano |
7d535a |
} elsif ($block_size != $2) {
|
|
kusano |
7d535a |
die "$PROG: block-size: $block_size != $2\n";
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
next;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if (/^\s*LZO\s.*library\s+\(v\s*([\w\.\s]+)\s*\,\s*([^\)]+)\)/) {
|
|
kusano |
7d535a |
$lzo_version_string = $1;
|
|
kusano |
7d535a |
$lzo_version_date = $2;
|
|
kusano |
7d535a |
next;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if (/^\s*(\S+(\s+\[\S+\])?)\s*(\|.*\|)\s*$/i) {
|
|
kusano |
7d535a |
if ($1 ne $alg) {
|
|
kusano |
7d535a |
&footer($1);
|
|
kusano |
7d535a |
&header($1);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
$line = $3;
|
|
kusano |
7d535a |
&stats(*line);
|
|
kusano |
7d535a |
print "$line\n" if (!$opt_summary_only);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
&footer($1);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
&summary();
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
exit(0);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub stats {
|
|
kusano |
7d535a |
local (*l) = @_;
|
|
kusano |
7d535a |
local ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ($l !~ /^\|\s*(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\.]+\s+)?([\d\.]+\s+)?([\d\.]+)\s+([\d\.]+)\s*\|/) {
|
|
kusano |
7d535a |
die $_;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$n++;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$x1 = $1; $x2 = $2; $x3 = $3; $x4 = $4;
|
|
kusano |
7d535a |
$x5 = ($x2 > 0) ? $x4 * 100.0 / $x2 : 0.0;
|
|
kusano |
7d535a |
$x6 = ($x2 > 0) ? $x4 * 8.0 / $x2 : 0.0;
|
|
kusano |
7d535a |
$x7 = $7; $x8 = $8;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# convert from kB/s to MB/s (for old versions of lzotest)
|
|
kusano |
7d535a |
if ($x7 =~ /\.\d\d$/) { $x7 = $x7 / 1000.0; }
|
|
kusano |
7d535a |
if ($x8 =~ /\.\d\d$/) { $x8 = $x8 / 1000.0; }
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ($opt_clear_time) {
|
|
kusano |
7d535a |
$x7 = $x8 = 0.0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$s[0] += $x2;
|
|
kusano |
7d535a |
$s[1] += $x3;
|
|
kusano |
7d535a |
$s[2] += $x4;
|
|
kusano |
7d535a |
$s[3] += $x5;
|
|
kusano |
7d535a |
$s[4] += $x6;
|
|
kusano |
7d535a |
if ($x7 > 0) {
|
|
kusano |
7d535a |
$s[5] += 1.0 / $x7; $sn[5] += 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if ($x8 > 0) {
|
|
kusano |
7d535a |
$s[6] += 1.0/ $x8; $sn[6] += 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$x1 =~ s/\s+$//;
|
|
kusano |
7d535a |
$l = sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |",
|
|
kusano |
7d535a |
$x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub header {
|
|
kusano |
7d535a |
local ($t) = @_;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$alg = $t;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# reset stats
|
|
kusano |
7d535a |
$n = 0;
|
|
kusano |
7d535a |
@s = (0, 0, 0, 0.0, 0.0, 0.0, 0.0);
|
|
kusano |
7d535a |
@sn = (0, 0, 0, 0, 0, 0, 0);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
return if $opt_summary_only;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
print "\n$alg\n\n";
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
print <
|
|
kusano |
7d535a |
| File Name Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
|
|
kusano |
7d535a |
| --------- ------ --- ------ ----- ---- -------- -------- |
|
|
kusano |
7d535a |
EndOfString
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub footer {
|
|
kusano |
7d535a |
local ($t) = @_;
|
|
kusano |
7d535a |
local ($shm5, $shm6);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
return unless $alg;
|
|
kusano |
7d535a |
die if $n <= 0;
|
|
kusano |
7d535a |
die if $s[0] <= 0;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# harmonic mean
|
|
kusano |
7d535a |
$shm5 = $s[5] > 0 ? $sn[5] / $s[5] : 0.0;
|
|
kusano |
7d535a |
$shm6 = $s[6] > 0 ? $sn[6] / $s[6] : 0.0;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
push(@algs,$alg);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$average{$alg} =
|
|
kusano |
7d535a |
sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |\n",
|
|
kusano |
7d535a |
"Average", $s[0]/$n, $s[1]/$n, $s[2]/$n,
|
|
kusano |
7d535a |
$s[3]/$n, $s[4]/$n,
|
|
kusano |
7d535a |
$shm5, $shm6);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$total{$alg} =
|
|
kusano |
7d535a |
sprintf("| %-14s %10d %5d %9d %6.1f %5.2f %9.3f %9.3f |\n",
|
|
kusano |
7d535a |
"Total", $s[0], $s[1], $s[2],
|
|
kusano |
7d535a |
$s[2]/$s[0]*100, $s[2]/$s[0]*8,
|
|
kusano |
7d535a |
$shm5, $shm6);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
return if $opt_summary_only;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
print $average{$alg};
|
|
kusano |
7d535a |
print $total{$alg};
|
|
kusano |
7d535a |
print $sep, "\n";
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$sort_mode = 0;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub cmp_by_ratio {
|
|
kusano |
7d535a |
local ($aa, $bb);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ($sort_mode == 0) {
|
|
kusano |
7d535a |
$aa = $average{$a};
|
|
kusano |
7d535a |
$bb = $average{$b};
|
|
kusano |
7d535a |
} elsif ($sort_mode == 1) {
|
|
kusano |
7d535a |
$aa = $total{$a};
|
|
kusano |
7d535a |
$bb = $total{$b};
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
die;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
($aa =~ m%^\s*\|\s+\S+\s+\d+\s+\d+\s+\d+\s+(\S+)%) || die;
|
|
kusano |
7d535a |
$aa = $1;
|
|
kusano |
7d535a |
($bb =~ m%^\s*\|\s+\S+\s+\d+\s+\d+\s+\d+\s+(\S+)%) || die;
|
|
kusano |
7d535a |
$bb = $1;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# $aa < $bb;
|
|
kusano |
7d535a |
$aa cmp $bb;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub summary {
|
|
kusano |
7d535a |
local ($l);
|
|
kusano |
7d535a |
local (@k);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$sort_mode = 0;
|
|
kusano |
7d535a |
if ($opt_sort_summary_by_name) {
|
|
kusano |
7d535a |
@k = sort(@algs);
|
|
kusano |
7d535a |
} elsif ($opt_sort_summary_by_ratio) {
|
|
kusano |
7d535a |
@k = sort(cmp_by_ratio @algs);
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
@k = @algs;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
print "\n\n";
|
|
kusano |
7d535a |
print "Summary of average values\n\n";
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
print <
|
|
kusano |
7d535a |
| Algorithm Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
|
|
kusano |
7d535a |
| --------- ------ --- ------ ----- ---- -------- -------- |
|
|
kusano |
7d535a |
EndOfString
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (@k) {
|
|
kusano |
7d535a |
$l = $average{$_};
|
|
kusano |
7d535a |
$l =~ s/Average[\s]{7}/sprintf("%-14s",$_)/e;
|
|
kusano |
7d535a |
print $l;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$sort_mode = 1;
|
|
kusano |
7d535a |
if ($opt_sort_summary_by_name) {
|
|
kusano |
7d535a |
@k = sort(@algs);
|
|
kusano |
7d535a |
} elsif ($opt_sort_summary_by_ratio) {
|
|
kusano |
7d535a |
@k = sort(cmp_by_ratio @algs);
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
@k = @algs;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
print "\n\n";
|
|
kusano |
7d535a |
print "Summary of total values\n\n";
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
print <
|
|
kusano |
7d535a |
| Algorithm Length CxB ComLen Ratio% Bits Com MB/s Dec MB/s |
|
|
kusano |
7d535a |
| --------- ------ --- ------ ----- ---- -------- -------- |
|
|
kusano |
7d535a |
EndOfString
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (@k) {
|
|
kusano |
7d535a |
$l = $total{$_};
|
|
kusano |
7d535a |
$l =~ s/Total[\s]{9}/sprintf("%-14s",$_)/e;
|
|
kusano |
7d535a |
print $l;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
print $sep;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
# /***********************************************************************
|
|
kusano |
7d535a |
# //
|
|
kusano |
7d535a |
# ************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
sub intro {
|
|
kusano |
7d535a |
local ($bs) = @_;
|
|
kusano |
7d535a |
local ($v, $t, $x);
|
|
kusano |
7d535a |
local ($u, $uname_m, $uname_s, $uname_r);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$t = &ctime(time); chop($t);
|
|
kusano |
7d535a |
$t = sprintf("%-55s |", $t);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$v='';
|
|
kusano |
7d535a |
if ($lzo_version_string) {
|
|
kusano |
7d535a |
$v = $lzo_version_string;
|
|
kusano |
7d535a |
$v .= ', ' . $lzo_version_date if $lzo_version_date;
|
|
kusano |
7d535a |
$v = sprintf("%-55s |", $v);
|
|
kusano |
7d535a |
$v = sprintf("| LZO version : %s\n", $v);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ($bs % 1024 == 0) {
|
|
kusano |
7d535a |
$x = sprintf("%d (= %d kB)", $bs, $bs / 1024);
|
|
kusano |
7d535a |
} else {
|
|
kusano |
7d535a |
$x = sprintf("%d (= %.3f kB)", $bs, $bs / 1024.0);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
$x = sprintf("%-55s |", $x);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
$u='';
|
|
kusano |
7d535a |
if (1 == 1) {
|
|
kusano |
7d535a |
$uname_s = `uname -s`; $uname_s =~ s/^\s+//; $uname_s =~ s/\s+$//;
|
|
kusano |
7d535a |
$uname_r = `uname -r`; $uname_r =~ s/^\s+//; $uname_r =~ s/\s+$//;
|
|
kusano |
7d535a |
$uname_m = `uname -m`; $uname_m =~ s/^\s+//; $uname_m =~ s/\s+$//;
|
|
kusano |
7d535a |
if ($uname_s && $uname_m) {
|
|
kusano |
7d535a |
$u = $uname_s;
|
|
kusano |
7d535a |
$u .= ' ' . $uname_r if $uname_r;
|
|
kusano |
7d535a |
$u .= ' ' . $uname_m;
|
|
kusano |
7d535a |
$u = sprintf("%-55s |", $u);
|
|
kusano |
7d535a |
$u = sprintf("| Operating system : %s\n", $u);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
print <
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
+----------------------------------------------------------------------------+
|
|
kusano |
7d535a |
| DATA COMPRESSION TEST |
|
|
kusano |
7d535a |
| ===================== |
|
|
kusano |
7d535a |
| Time of run : $t
|
|
kusano |
7d535a |
$v$u| Context length : $x
|
|
kusano |
7d535a |
+----------------------------------------------------------------------------+
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Notes:
|
|
kusano |
7d535a |
- CxB is the number of independent blocks a file was splitted
|
|
kusano |
7d535a |
- MB/s is the speed measured in 1,000,000 uncompressed bytes per second
|
|
kusano |
7d535a |
- all averages are calculated from the un-rounded values
|
|
kusano |
7d535a |
- the average ratio & bits are calculated by the arithmetic mean
|
|
kusano |
7d535a |
- the average speed is calculated by the harmonic mean
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
EndOfString
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
__END__
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
### insert something like this after 'Time of run':
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
| Hardware : Intel Pentium 133, 64 MB RAM, 256 kB Cache |
|
|
kusano |
7d535a |
| Operating system : MS-DOS 7.10, HIMEM.SYS 3.95, DOS/4GW 1.97 |
|
|
kusano |
7d535a |
| Compiler : Watcom C32 10.5 |
|
|
kusano |
7d535a |
| Compiler flags : -mf -5r -oneatx |
|
|
kusano |
7d535a |
| Test suite : Calgary Corpus Suite |
|
|
kusano |
7d535a |
| Files in suite : 14 |
|
|
kusano |
7d535a |
| Timing accuracy : One part in 100 |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|