diff options
| author | Randy Morgan <[email protected]> | 2012-03-26 18:29:35 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-03-26 18:29:35 +0900 |
| commit | 42f45f4138a1f71b19411fd8600f2a2bce67a46b (patch) | |
| tree | bcef93a7c400d806f1f8aa7a4ebc08d359540d67 /test/benchmark.rb | |
| parent | d7ccb09a0aaac4564fe01a56305e68d41ee37f57 (diff) | |
| download | caxlsx-42f45f4138a1f71b19411fd8600f2a2bce67a46b.tar.gz caxlsx-42f45f4138a1f71b19411fd8600f2a2bce67a46b.zip | |
Quick and Dirty run on trying interpolated strings instead of nokogiri for sheet generation.
Diffstat (limited to 'test/benchmark.rb')
| -rw-r--r-- | test/benchmark.rb | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/benchmark.rb b/test/benchmark.rb new file mode 100644 index 00000000..bb9a7b7d --- /dev/null +++ b/test/benchmark.rb @@ -0,0 +1,81 @@ +#!/usr/bin/env ruby -s +# -*- coding: utf-8 -*- +$:.unshift "#{File.dirname(__FILE__)}/../lib" +require 'axlsx' +require 'csv' + +require 'benchmark' +row = [] +input = (32..126).to_a.pack('U*').chars.to_a +20.times { row << input.shuffle.join} +times = 1000 +Benchmark.bm(100) do |x| + # No Autowidth + x.report('axlsx_noautowidth') { + + p = Axlsx::Package.new + p.use_autowidth = false + wb = p.workbook + + #A Simple Workbook + + wb.add_worksheet do |sheet| + times.times do + sheet << row + end + end + p.serialize("example.xlsx") + } + + x.report('axlsx') { + p = Axlsx::Package.new + wb = p.workbook + + #A Simple Workbook + + wb.add_worksheet do |sheet| + times.times do + sheet << row + end + end + p.serialize("example.xlsx") + } + + x.report('axlsx_shared') { + p = Axlsx::Package.new + wb = p.workbook + + #A Simple Workbook + + wb.add_worksheet do |sheet| + times.times do + sheet << row + end + end + p.use_shared_strings = true + p.serialize("example.xlsx") + } + + x.report('axlsx_stream') { + p = Axlsx::Package.new + wb = p.workbook + + #A Simple Workbook + + wb.add_worksheet do |sheet| + times.times do + sheet << row + 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 |
