diff options
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 3 | ||||
| -rw-r--r-- | test/benchmark.rb | 3 | ||||
| -rw-r--r-- | test/profile.rb | 17 |
3 files changed, 8 insertions, 15 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 126b24cd..cfcb6118 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -444,6 +444,9 @@ module Axlsx v ? 1 : 0 else @type = :string + v.to_s + # TODO find a better way to do this as it accounts for 30% of + # processing time in benchmarking... ::CGI.escapeHTML(v.to_s) end end diff --git a/test/benchmark.rb b/test/benchmark.rb index d61aa7b2..33bf7d2c 100644 --- a/test/benchmark.rb +++ b/test/benchmark.rb @@ -4,11 +4,10 @@ $:.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 = 2000 +times = 3000 Benchmark.bmbm(30) do |x| x.report('axlsx_noautowidth') { diff --git a/test/profile.rb b/test/profile.rb index bce5d74e..0190dc16 100644 --- a/test/profile.rb +++ b/test/profile.rb @@ -1,31 +1,22 @@ #!/usr/bin/env ruby -s -# -*- coding: utf-8 -*- # Usage: # > ruby test/profile.rb -# > pprof.rb --gif /tmp/axlsx_noautowidth > /tmp/axlsx_noautowidth.gif +# > pprof.rb --gif /tmp/axlsx > /tmp/axlsx.gif # > open /tmp/axlsx_noautowidth.gif $:.unshift "#{File.dirname(__FILE__)}/../lib" require 'axlsx' -require 'csv' - -# require 'benchmark' require 'perftools' row = [] +# Taking worst case scenario of all string data input = (32..126).to_a.pack('U*').chars.to_a 20.times { row << input.shuffle.join} times = 3000 -PerfTools::CpuProfiler.start("/tmp/axlsx_noautowidth") do +PerfTools::CpuProfiler.start("/tmp/axlsx") do p = Axlsx::Package.new - #p.use_autowidth = false - #p.use_shared_strings = true - wb = p.workbook - - #A Simple Workbook - - wb.add_worksheet do |sheet| + p.workbook.add_worksheet do |sheet| times.times do sheet << row end |
