Sha256: 4db6e7e9496f6a9ffabe796178ca9594765656626967322e3cd565c5346b3b16

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Viiite
  class Command
    #
    # Run a benchmark and output raw data
    #
    # SYNOPSIS
    #   viiite #{command_name} [BENCHFILE]
    #
    # OPTIONS
    # #{summarized_options}
    #
    class Run < Quickl::Command(__FILE__, __LINE__)
      include Commons

      options do |opt|
        @runs = 1
        opt.on("--runs=[NB]",
               "Run the benchmark NB times") do |val|
          @runs = val.to_i
          @run_key = :run unless @run_key
        end
        @run_key = nil
        opt.on("--run-key=[KEY]",
               "Specify the run key (default to :run)") do |val|
          @run_key = val.to_sym
        end
      end

      def execute(argv)
        argv = requester.bdb.to_rel.collect{|t| t[:name]} if argv.empty?
        argv.each do |name|
          benchmark = single_source([name]) do |bdb, arg|
            bdb.benchmark(arg)
          end
          @runs.times do |run|
            benchmark.each do |tuple|
              tuple[@run_key] = run if @run_key
              puts Alf::Tools.to_ruby_literal(tuple)
            end
          end
        end
      end

    end # class Run
  end # class Command
end # module Viiite

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
viiite-0.2.0 lib/viiite/command/run.rb