D
David G. Andersen
I'm still in 1.8.1-land, so this may be old news, but
GzipReader is (painfully) slow compared to using zcat
to accomplish the same thing:
The code:
#!/scratch/ruby/bin/ruby
require 'zlib'
f = ARGV[0]
s = Time.new
infile = Zlib::GzipReader.new(File.new(f, "r"))
#infile = IO.popen("zcat #{f}", "r")
linecount = 0
infile.each_line { |l|
linecount += 1
}
e = Time.new
print "Read #{linecount} lines in #{e - s} seconds\n"
------------------------------
Tested on:
FreeBSD port-installed ruby 1.8.1
Freshly compiled 1.8.1
Freshly compiled 1.8.1 with CFLAGS=-O2
CVS version, CFLAGS=-O2
FBSD 1.8.1 1.8.1, O0 1.8.1 -O2 CVS, -O2
popen zcat: 2.3 2.3 2.3 2.3
GzipReader: 5.8 9.2 5.8 5.9
Yowza. Before I poke more, is this expected, or a known
slowness issue?
-Dave
GzipReader is (painfully) slow compared to using zcat
to accomplish the same thing:
The code:
#!/scratch/ruby/bin/ruby
require 'zlib'
f = ARGV[0]
s = Time.new
infile = Zlib::GzipReader.new(File.new(f, "r"))
#infile = IO.popen("zcat #{f}", "r")
linecount = 0
infile.each_line { |l|
linecount += 1
}
e = Time.new
print "Read #{linecount} lines in #{e - s} seconds\n"
------------------------------
Tested on:
FreeBSD port-installed ruby 1.8.1
Freshly compiled 1.8.1
Freshly compiled 1.8.1 with CFLAGS=-O2
CVS version, CFLAGS=-O2
FBSD 1.8.1 1.8.1, O0 1.8.1 -O2 CVS, -O2
popen zcat: 2.3 2.3 2.3 2.3
GzipReader: 5.8 9.2 5.8 5.9
Yowza. Before I poke more, is this expected, or a known
slowness issue?
-Dave