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