summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-05-23 18:02:47 -0700
committerPaul Kmiec <[email protected]>2023-05-23 18:02:47 -0700
commit5dea3e7092fb3a4667cbb50a9885d0ec4aed77b7 (patch)
tree03ffa9ebb1e72bc5f6ba7374a50dbbf3ecf373f0 /test
parent75cdbc5b10d4813316b38a3588829debadc7fb7d (diff)
downloadcaxlsx-5dea3e7092fb3a4667cbb50a9885d0ec4aed77b7.tar.gz
caxlsx-5dea3e7092fb3a4667cbb50a9885d0ec4aed77b7.zip
Add benchmark with merge cells
This is an extreme case, but it really shows the impact of merging cells.
Diffstat (limited to 'test')
-rwxr-xr-xtest/benchmark.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/benchmark.rb b/test/benchmark.rb
index d5ccdf64..fb4d7050 100755
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -11,9 +11,22 @@ input1 = (32..126).to_a.pack('U*').chars.to_a # these will need to be escaped
input2 = (65..122).to_a.pack('U*').chars.to_a # these do not need to be escaped
10.times { row << input1.shuffle.join }
10.times { row << input2.shuffle.join }
-times = 3000
+times = 3_000
Benchmark.bmbm(30) do |x|
+ x.report('axlsx_merged_cells') do
+ p = Axlsx::Package.new
+ p.workbook do |wb|
+ wb.add_worksheet do |sheet|
+ times.times do
+ sheet << row
+ sheet.merge_cells(sheet.rows.last.cells)
+ end
+ end
+ end
+ p.serialize("example_axlsx_merged_cells.xlsx")
+ end
+
x.report('axlsx_noautowidth') do
p = Axlsx::Package.new
p.workbook do |wb|
@@ -85,4 +98,4 @@ Benchmark.bmbm(30) do |x|
end
end
end
-File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx", "example_zip_command.xlsx")
+File.delete("example_axlsx_merged_cells.xlsx", "example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx", "example_zip_command.xlsx")