forked from gabynaiman/xlsx_sax_reader
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRakefile
74 lines (69 loc) · 1.68 KB
/
Rakefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "bundler/gem_tasks"
require "rspec/core/rake_task"
Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
task :bench do
require 'benchmark'
require 'axlsx'
require 'saxlsx'
require 'rubyXL'
require 'simple_xlsx_reader'
require 'creek'
path = "tmp/bench.xlsx"
unless File.exists?(path)
puts "* Generating #{path}"
FileUtils.mkdir_p File.dirname(path)
Axlsx::Package.new do |p|
money_style = p.workbook.styles.add_style(
num_fmt: 5, format_code: "€0.000"
)
p.workbook.add_worksheet(:name => "Pie Chart") do |sheet|
10000.times do
sheet.add_row(
[Date.today, Time.now, 1000, 3.14, "Long" * 100],
types: [:date, :time, :integer, :float, :string],
style: [nil, nil, nil, money_style, nil]
)
end
end
p.use_shared_strings = true
p.serialize(path)
end
end
Benchmark.benchmark('', 20) do |x|
x.report "creek" do
w = Creek::Book.new path
w.sheets.each do |s|
s.rows.each do |r|
r.values.inspect
end
end
end
x.report "rubyXL" do
w = RubyXL::Parser.parse path
w.worksheets.each do |s|
s.each do |r|
r.cells.map(&:value).inspect
end
end
end
x.report "saxlsx" do
Saxlsx::Workbook.open path do |w|
w.sheets.each do |s|
s.rows.each do |r|
r.to_a.inspect
end
end
end
end
x.report "simple_xlsx_reader" do
w = SimpleXlsxReader.open path
w.sheets.each do |s|
s.rows.each do |r|
r.to_a.inspect
end
end
end
end
end