Sha256: 2d06fd8c70941d97758a06016e6278c4484f62c452810654d086244513d54c05

Contents?: true

Size: 1.55 KB

Versions: 20

Compression:

Stored size: 1.55 KB

Contents

#!/usr/bin/env ruby -s
$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
require 'csv'
require 'benchmark'
Axlsx::trust_input = true
row = []
input = (32..126).to_a.pack('U*').chars.to_a
20.times { row << input.shuffle.join}
times = 3000
Benchmark.bmbm(30) do |x|

  x.report('axlsx_noautowidth') {
    p = Axlsx::Package.new
    p.workbook do |wb|
      wb.add_worksheet do |sheet|
        times.times do
          sheet << row
        end
      end
    end
    p.use_autowidth = false
    p.serialize("example_noautowidth.xlsx")
  }

  x.report('axlsx') {
    p = Axlsx::Package.new
    p.workbook do |wb|
      wb.add_worksheet do |sheet|
        times.times do
          sheet << row
        end
      end
    end
    p.serialize("example_autowidth.xlsx")
  }

  x.report('axlsx_shared') {
    p = Axlsx::Package.new
    p.workbook do |wb|
      wb.add_worksheet do |sheet|
        times.times do
          sheet << row
        end
      end
    end
    p.use_shared_strings = true
    p.serialize("example_shared.xlsx")
  }

  x.report('axlsx_stream') {
    p = Axlsx::Package.new
    p.workbook do |wb|
      wb.add_worksheet do |sheet|
        times.times do
          sheet << row
        end
      end
    end
    s = p.to_stream()
    File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
  }

  x.report('csv') {
    CSV.open("example.csv", "wb") do |csv|
      times.times do
        csv << row
      end
    end
  }
end
File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx")

Version data entries

20 entries across 20 versions & 6 rubygems

Version Path
caxlsx-3.1.1 test/benchmark.rb
caxlsx-3.1.0 test/benchmark.rb
bonio-axlsx-2.2.3 test/benchmark.rb
caxlsx-3.0.4 test/benchmark.rb
caxlsx-3.0.3 test/benchmark.rb
caxlsx-3.0.2 test/benchmark.rb
caxlsx-2.0.2 test/benchmark.rb
caxlsx-3.0.1 test/benchmark.rb
caxlsx-3.0.0 test/benchmark.rb
axlsx-alt-3.0.1 test/benchmark.rb
axlsx-alt-3.0.0 test/benchmark.rb
axlsx-3.0.0.pre test/benchmark.rb
bonio-axlsx-2.2.2 test/benchmark.rb
bonio-axlsx-2.2.1 test/benchmark.rb
dg-axlsx-2.1.0 test/benchmark.rb
axlsx-2.1.0.pre test/benchmark.rb
l_axlsx-2.0.1 test/benchmark.rb
axlsx-2.0.1 test/benchmark.rb
axlsx-2.0.0 test/benchmark.rb
axlsx-1.3.6 test/benchmark.rb