Sha256: 7d2a5023535eb647208c019ac9e488920050e28396a5b6583bea1560f29cb615

Contents?: true

Size: 1.78 KB

Versions: 4

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
      Osheet::Workbook.new(Osheet::XmlssWriter.new(:pp => 2), {
        :bench_row_count => @row_count,
        :runner => @runner,
        :data_values => {
          'number'   => 1,
          'currency' => 45.23,
          'text'     => "<>&'\"/"
        }
      }) {
        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.sort.each do |label|
            column {
              width 200
              meta(:label => label)
            }
          end

          row :header

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

end

class OsheetXmlssBenchRunner

  ROWS = [1_000]#, 100, 1_000, 10_000, 100_000]

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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osheet-xmlss-1.0.1 bench/bench_runner.rb
osheet-xmlss-1.0.0 bench/bench_runner.rb
osheet-xmlss-1.0.0.rc.3 bench/bench_runner.rb
osheet-xmlss-1.0.0.rc.2 bench/bench_runner.rb