module BigBench # This module is used to keep all the command line outputs in a single place. The output module gets notified of the code and # can then do what it want's with this information. module Output mattr_accessor :start mattr_accessor :trackings @start = Time.now @trackings = 1 def self.start puts "-> Started BigBench at #{@start = Time.now}\n" $stdout.flush end def self.done puts "\n-> Done. Took #{Time.now - @start} seconds." $stdout.flush end def self.reset puts "-> Resetting everything." $stdout.flush end def self.loaded_tests puts "\n-> Loading\n" puts "Loaded #{BigBench.benchmarks.size} benchmarks. Benchmark will take #{BigBench.duration} seconds" $stdout.flush end def self.running_benchmarks puts "\n-> Running\n" puts "Running #{BigBench.benchmarks.size} benchmarks." $stdout.flush Thread.new{ loop { sleep(1) progress = Time.now - @start remaining = BigBench.duration.to_i - progress percent = ((progress.to_f / BigBench.duration.to_f).to_f * 100).to_i print "\r#{percent}% - #{progress.to_i} seconds elapsed. #{remaining.to_i} seconds remaining." if percent > 99 print "\r100% Done \n" break end } } end def self.finished_running_benchmarks puts "Finished #{BigBench.benchmarks.size} benchmarks." $stdout.flush end def self.writing_trackings(count) target = BigBench.config.mode == :bot ? 'redis' : BigBench.config.output puts "\n-> Writing\n" puts "Writing #{@trackings = count} trackings to #{target}." $stdout.flush end def self.wrote_trackings(count) percent = ((count.to_f / @trackings.to_f).to_f * 100).to_i $stdout.flush print "\r#{percent}%" end def self.finished_writing_trackings(count) print "\r100% Done \n" target = BigBench.config.mode == :bot ? 'redis' : BigBench.config.output puts "\nWrote #{count} trackings to #{target}." $stdout.flush end def self.deployed_test puts "Deployed test to the redis store." $stdout.flush end def self.starting_bots_loop puts "\n-> Running\n" puts "Running benchmarks on bots." end def self.running_bots_loop(bots) progress = Time.now - @start remaining = BigBench.duration.to_i - progress percent = ((progress.to_f / BigBench.duration.to_f).to_f * 100).to_i info = " - Waiting for bots to finish" if percent > 100 $stdout.flush print "\r#{percent}% - #{progress.to_i} seconds elapsed. #{remaining.to_i} seconds remaining. #{bots.size} Active Bots#{info} " end def self.finished_bots_loop print "\r100% Done \n" puts "Finished bots test." $stdout.flush end def self.bot_is_checking puts "Checking for new tests at #{Time.now}" $stdout.flush end def self.bot_received_test_instructions puts "\n-> Received\n" puts "Received test instructions\n" $stdout.flush end end end