sroller icon

Benchmark CSV gems

sroller | PRO | 11/06/18 04:31:45 PM UTC | 0 ⭐ | 7292 👁️ | Never ⏰ | []
Ruby |

690 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/env ruby
#
# test file from the weather station of the University of Waterloo, Ontario, Canada
# 
 
require 'httpclient'
require 'csvreader'
require 'csv'
require 'benchmark/ips'
 
URL= 'http://weather.uwaterloo.ca/download/Hobo_15minutedata_2017.csv'
FILE = 'uwaterloo_weatherdata_2017.csv'
 
if not File.exists?(FILE)
  puts "fetch #{URL}"
  http = HTTPClient.new
  csv = http.get_content(URL)
  File.open(FILE, "w") {|f| f.write(csv) }
end
 
 
Benchmark.ips(20) do |x|
    x.report("builtin csv (v#{CSV::VERSION})") { CSV.read(FILE, { headers: true, converters: :all }) }
    x.report("csv reader (v#{CsvReader::VERSION})") { Csv.read(FILE, { headers: true, converters: :all }) }
    x.compare!
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎