Sha256: 7dc3bb20c3dce89a8d2622964138f709ff25c04ee3b4c4f598109386a67b7372

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

class BenchmarkCLI
  module Compare
    # @abstract
    #
    # Base class for comparison benchmarks.
    class Base
      include Helpers

      def initialize(implementations)
        @implementations = implementations
      end

      def call
        header self.class::TITLE

        Benchmark.ips do |benchmark|
          benchmark.config(stats: :bootstrap, confidence: 95)

          report_implementations(benchmark)

          benchmark.compare!
        end
      end

      private

      def report_implementations(benchmark)
        @implementations.each do |implementation|
          report_implementation(benchmark, IMPLEMENTATIONS[implementation])
        end
      end

      def report_implementation(benchmark, cfg)
        mode = cfg[:mode]
        title = "#{cfg[:title]} (#{MODES[mode]})"
        klass = cfg[:classes][self.class::NAME]

        case mode
        when :class_call then report_class_call(benchmark, title, klass)
        when :instance_call then report_instance_call(benchmark, title, klass)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flows-0.6.0 bin/benchmark_cli/compare/base.rb
flows-0.5.1 bin/benchmark_cli/compare/base.rb
flows-0.5.0 bin/benchmark_cli/compare/base.rb
flows-0.4.0 bin/benchmark_cli/compare/base.rb