Sha256: db41acf0fe249bcdf6ee3321cf59c422b69201ccd8ebca8be13ccbe8084fb566

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8
require 'benchmark/timing'
require 'benchmark/compare'
require 'benchmark/ips/report'
require 'benchmark/ips/job'

module Benchmark
  module IPS
    VERSION = "2.0.0"
    CODENAME = "Springtime Hummingbird Dance"

    def ips(time=nil, warmup=nil)
      suite = nil

      sync, $stdout.sync = $stdout.sync, true

      if defined? Benchmark::Suite and Suite.current
        suite = Benchmark::Suite.current
      end

      quiet = suite && !suite.quiet?

      job = Job.new({:suite => suite,
                     :quiet => quiet
      })

      job_opts = {}
      job_opts[:time] = time unless time.nil?
      job_opts[:warmup] = warmup unless warmup.nil?

      job.config job_opts

      yield job

      $stdout.puts "Calculating -------------------------------------" unless quiet

      job.run_warmup

      $stdout.puts "-------------------------------------------------" unless quiet

      job.run

      $stdout.sync = sync

      if job.compare?
        job.run_comparison
      end

      return job.full_report
    end
  end

  extend Benchmark::IPS
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
benchmark-ips-2.0.0 lib/benchmark/ips.rb