Sha256: c00a946cb0cf3ad80eb09ee90eaf2254a29c6ce4cc9e1fc849226bb6d04be554

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 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
      EventMachine.run {
        
        # Start Timer
        Thread.new { sleep(BigBench.duration.to_i); EventMachine.stop }
        
        # Start Benchmarks
        BigBench.benchmarks.each{ |benchmark| benchmark.run! }
      }
    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)
    BigBench::Output.loaded_tests
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bigbench-0.0.6 lib/bigbench/runner.rb
bigbench-0.0.5 lib/bigbench/runner.rb