summaryrefslogtreecommitdiffhomepage
path: root/test/profile_memory.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/profile_memory.rb')
-rwxr-xr-xtest/profile_memory.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/profile_memory.rb b/test/profile_memory.rb
new file mode 100755
index 00000000..15547b37
--- /dev/null
+++ b/test/profile_memory.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby -s
+# frozen_string_literal: true
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require 'axlsx'
+require 'memory_profiler'
+
+# Axlsx.trust_input = true
+
+row = []
+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 }
+
+report = MemoryProfiler.report do
+ p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+ 10_000.times do
+ sheet << row
+ end
+ end
+ p.serialize("example_memory.xlsx", zip_command: 'zip')
+end
+report.pretty_print
+
+File.delete("example_memory.xlsx")