Sha256: 673088e486523a1472bd9ad6ceeb5936073ef3365e9db6c9de52b6ccbb63db8a

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'whysoslow'
require 'stringio'

require 'osheet/xmlss'

class OsheetXmlssBenchResults

  def initialize(row_count)
    @row_count = row_count
    @printer = Whysoslow::DefaultPrinter.new({
      :title => "#{@row_count} rows",
      :verbose => true
    })
    @runner = Whysoslow::Runner.new(@printer)
  end

  def run
    @runner.run do
      data_values = {
        :number   => 1,
        :text     => 'text',
        :currency => 123.45,
        :text     => "<>&'\"/",
        :currency => 45.23
      }

      outstream = StringIO.new(out = "")
      outstream << Osheet::Workbook.new(Osheet::XmlssWriter.new(:pp => 2), {
        :bench_row_count => @row_count,
        :runner => @runner
      }) {
        title "bench"

        template(:row, :header) {
          columns.each do |column|
            cell {
              data column.meta[:label]
            }
          end
        }

        template(:row, :data) { |values|
          columns.each do |col|
            cell {
              data values[col.meta[:label]]
              format col.meta[:label]
            }
          end
        }

        worksheet {
          name "bench results"

          data_values.keys.each do |label|
            column {
              width 200
              meta(:label => label)
            }
          end

          row :header

          10.times do |i|
            (bench_row_count / 10).times do
              row :data, data_values
            end
            runner.snapshot("#{((i+1)*10).to_s.rjust(3)}%")
          end
        }
      }.to_data
    end
  end

end

class OsheetXmlssBenchRunner

  ROWS = [10, 100, 1000]#, 10000]#, 30000]

  def initialize
    puts "Benchmark Results:"
    puts
    ROWS.each do |size|
      OsheetXmlssBenchResults.new(size).run
      puts
    end
    puts
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
osheet-xmlss-1.0.0.rc.1 bench/bench_runner.rb