Fri 05 Oct 2012 04:28:49 PM UTC, original submission:
The following script
<<<<SNIP
function testcase(n)
system("rm -f random.dat random.dat.gz");
A=rand(1,n);
save -z random.dat.gz A;
# Use -z to uncompress
tic;
load random.dat.gz;
fprintf(stderr, "Direct: %en", toc());
# Uncompress manually
tic;
system("gunzip random.dat.gz");
load random.dat;
fprintf(stderr, "Indirect: %en", toc());
<<<<SNAP
creates a random 1xn matrix, and writes it to a gzip-compressed file. Then it compares how long it takes to
(1) read it using `load -z` and to
(2) uncompress it through a call to gunzip and then `load` it.
While the overhead for the call to gzip dominates at first, with n=10000, `load -z` is three orders of magnitudes slower than the indirect approach for me:
% octave --eval 'testcase(1000)' >/dev/null
Direct: 2.528620e-01
Indirect: 1.927996e-02
% octave --eval 'testcase(10000)' >/dev/null
Direct: 2.424446e+01
Indirect: 3.546500e-02
I can reproduce this with octave 3.6.3 on two machines.
Octave 3.2.4, which is installed on one of those machines as well, does not show this behaviour:
% /usr/bin/octave --eval 'testcase(10000)' >/dev/null
Direct: 1.430511e-02
Indirect: 1.741195e-02
|