Sha256: 64b79a4ae46cc951a2b707589c04b591c7ba6b3b7fcd94d3ec3b6fdf4340f1c1

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module BigBench
  
  # The runner runs all available benchmarks and returns as soon as all of them are finished. Additionally it allows the loading
  # of reciepts from files or the redis storage.
  module Runner
    
    # Is thrown when no benchmarks are defined
    class NoBenchmarksDefined < StandardError
      def message
        "Sorry, I couldn't find any benchmarks!"
      end
    end
    
    # Runs all benchmarks
    def self.run!
      raise NoBenchmarksDefined.new if BigBench.benchmarks.empty?
      
      # Run all benchmarks
      @running_threads = []
      BigBench.benchmarks.each do |benchmark|
        @running_threads << Thread.new{ benchmark.run! }
      end
      
      # Wait for them to finish
      @running_threads.each{ |thread| thread.join }
    end
    
  end
  
  # Runs all initialized benchmarks
  def self.run!
    BigBench::Output.running_benchmarks
    Runner.run!
    BigBench::Output.finished_running_benchmarks
  end
  
  # Loads a test from a string file that is either parsed from a local file or retreived from the key-value store.
  #
  #    benchmark_string = 'benchmark "index page" => "http://localhost:3000" do
  #        get "/"
  #    end'
  #    
  #    BigBench.load_test!(benchmark_string)
  #
  def self.load_test!(test)
    BigBench::Benchmark.reset!
    eval(test)
    check_config!
    BigBench::Output.loaded_tests
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bigbench-0.0.1 lib/bigbench/runner.rb