#!/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
0 B
|👍
/👎
0 B
|👍
/👎