Skip to content

Instantly share code, notes, and snippets.

@spuyet
Last active June 29, 2016 12:49
Show Gist options
  • Save spuyet/2188f06d6a5b489c23786dc637276120 to your computer and use it in GitHub Desktop.
Save spuyet/2188f06d6a5b489c23786dc637276120 to your computer and use it in GitHub Desktop.
Benchmark XLSX gem wi

With a 1000 rows .xlsx file

Rehearsal ------------------------------------------
rubyXL   0.540000   0.010000   0.550000 (  0.552050)
creek    0.330000   0.000000   0.330000 (  0.327936)
roo      0.410000   0.020000   0.430000 (  0.425322)
--------------------------------- total: 1.310000sec

             user     system      total        real
rubyXL   0.520000   0.000000   0.520000 (  0.521278)
creek    0.310000   0.000000   0.310000 (  0.314996)
roo      0.360000   0.000000   0.360000 (  0.371896)

require 'benchmark'
require 'rubyXL'
require 'creek'
require 'roo'

file_path = ARGV[0]
Benchmark.bmbm(6) do |x|

  x.report 'rubyXL' do
    workbook = RubyXL::Parser.parse(file_path)
    worksheet = workbook[0]
    worksheet.each do |row|
      row.cells.each { |c| c }
    end
  end

  x.report 'creek' do |x|
    book = Creek::Book.new(file_path)
    sheet = book.sheets[0]
    sheet.rows.each do |row|
      row.each { |c| c }
    end
  end

  x.report 'roo' do |x|
    book = Roo::Spreadsheet.open(file_path)
    sheet = book.sheet(0)
    sheet.each_row_streaming do |row|
      row.each { |c| c }
    end
  end

end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment