-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbenchmark.rb
More file actions
executable file
·51 lines (37 loc) · 843 Bytes
/
benchmark.rb
File metadata and controls
executable file
·51 lines (37 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gemspec
gem "benchmark-memory"
gem "benchmark-perf"
end
def bench_perf(sheet)
result = Benchmark::Perf.cpu(repeat: 5) do
sheet.each do |row|
row.each do |cell|
end
end
end
puts "Performance benchmark: #{result.avg}s avg #{result.stdev}s stdev"
end
def bench_mem(sheet)
Benchmark.memory do |bm|
bm.report do
sheet.each do |row|
row.each do |cell|
end
end
end
end
end
puts RUBY_DESCRIPTION
file = File.read("test/files/10k-sheet.xlsx")
workbook = Xsv.open(file)
puts "--- ARRAY MODE ---"
bench_perf(workbook.sheets[0])
bench_mem(workbook.sheets[0])
puts "\n--- HASH MODE ---"
workbook.sheets[0].parse_headers!
bench_perf(workbook.sheets[0])
bench_mem(workbook.sheets[0])