Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comparison of memory usage: AXLSX vs. rubyXL
# frozen_string_literal: true
require 'axlsx'
require 'rubyXL'
require 'memory_profiler'
rows = 1_000
columns = 20
report = MemoryProfiler.report do
# axlsx
Axlsx::Package.new do |p|
p.workbook.add_worksheet(name: "Test") do |sheet|
rows.times do
sheet.add_row ["test data"] * columns
end
end
p.serialize('tmp/test_axlsx.xlsx')
end
# rubyXL
workbook = RubyXL::Workbook.new
worksheet = workbook.worksheets[0]
worksheet.sheet_name = 'Test'
rows.times do |r|
worksheet.insert_row(r)
columns.times do |c|
worksheet.insert_cell(r, c, "test data")
end
end
workbook.write('tmp/test_rubyxl.xlsx')
end
report.pretty_print
# rows = 100
# columns = 20
#
# retained memory by gem
# -----------------------------------
# 119888 axlsx-3.0.0.pre
# 5384 rubyXL-3.3.30
# 1527 pathname
# 195 rubyzip-1.2.1
# 80 htmlentities-4.3.4
# 40 nokogiri-1.8.4
# 40 other
# 40 singleton
#
# ===================================
#
# rows = 1_000
# columns = 20
#
# retained memory by gem
# -----------------------------------
# 1102664 axlsx-3.0.0.pre
# 5384 rubyXL-3.3.30
# 1527 pathname
# 195 rubyzip-1.2.1
# 80 htmlentities-4.3.4
# 40 nokogiri-1.8.4
# 40 other
# 40 singleton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.