Created
May 31, 2011 14:45
-
-
Save jcalvert/1000620 to your computer and use it in GitHub Desktop.
BAMFCSV vs FasterCSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'bamfcsv' | |
require 'csv' | |
glob,totalsize,rows,filetime,bamftime,fastertime=Dir.glob("*.csv"),0,[],Benchmark::Tms.new,Benchmark::Tms.new,Benchmark::Tms.new | |
content=nil | |
glob.each{|file| | |
filetime.add!{Benchmark.measure{ content = IO.read(file).rstrip.force_encoding("ISO-8859-1") }} | |
totalsize+=content.size | |
bamftime.add!{Benchmark.measure{BAMFCSV.parse(content){|row| rows << row}}} | |
rows.clear | |
fastertime.add!{Benchmark.measure{CSV.parse(content){|row| rows << row}}} | |
rows.clear | |
} | |
p 'Directory size: '+totalsize.to_s, filetime, bamftime, fastertime | |
-------------------------------- | |
"Directory size: 92201564" | |
0.230000 0.130000 0.000000 ( 0.374815) | |
11.900000 0.240000 0.000000 ( 12.112743) | |
44.320000 0.390000 0.000000 ( 44.662258) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment