Module: BigBench::Output

Defined in:
lib/bigbench/output.rb

Overview

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.

Class Method Summary collapse

Class Method Details

.bot_is_checkingObject



104
105
106
107
# File 'lib/bigbench/output.rb', line 104

def self.bot_is_checking
  puts "#{Time.now}: Checking for new test plan"
  $stdout.flush
end

.bot_received_test_instructionsObject



109
110
111
112
# File 'lib/bigbench/output.rb', line 109

def self.bot_received_test_instructions
  puts "#{Time.now}: Received new test plan"
  $stdout.flush
end

.deployed_testObject



79
80
81
82
# File 'lib/bigbench/output.rb', line 79

def self.deployed_test
  puts "Deployed test to the redis store."
  $stdout.flush
end

.doneObject



18
19
20
21
# File 'lib/bigbench/output.rb', line 18

def self.done
  puts "\n-> Done. Took #{Time.now - @start} seconds."
  $stdout.flush
end

.finished_bots_loopObject



98
99
100
101
102
# File 'lib/bigbench/output.rb', line 98

def self.finished_bots_loop
  print "\r100% Done                                                                                                            \n"
  puts "Finished bots test."
  $stdout.flush
end

.finished_running_benchmarksObject



54
55
56
57
# File 'lib/bigbench/output.rb', line 54

def self.finished_running_benchmarks
  puts "Finished #{BigBench.benchmarks.size} benchmarks."
  $stdout.flush
end

.finished_writing_trackings(count) ⇒ Object



72
73
74
75
76
77
# File 'lib/bigbench/output.rb', line 72

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

.loaded_testsObject



28
29
30
31
32
# File 'lib/bigbench/output.rb', line 28

def self.loaded_tests
  puts "\n-> Loading\n"
  puts "Loaded #{BigBench.benchmarks.size} benchmarks. Benchmark will take #{BigBench.duration} seconds"
  $stdout.flush
end

.resetObject



23
24
25
26
# File 'lib/bigbench/output.rb', line 23

def self.reset
  puts "-> Resetting everything."
  $stdout.flush
end

.running_benchmarksObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bigbench/output.rb', line 34

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

.running_bots_loop(bots) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/bigbench/output.rb', line 89

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

.startObject



13
14
15
16
# File 'lib/bigbench/output.rb', line 13

def self.start
  puts "-> Started BigBench at #{@start = Time.now}\n"
  $stdout.flush
end

.starting_bots_loopObject



84
85
86
87
# File 'lib/bigbench/output.rb', line 84

def self.starting_bots_loop
  puts "\n-> Running\n"
  puts "Running benchmarks on bots."
end

.writing_trackings(count) ⇒ Object



59
60
61
62
63
64
# File 'lib/bigbench/output.rb', line 59

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

.wrote_trackings(count) ⇒ Object



66
67
68
69
70
# File 'lib/bigbench/output.rb', line 66

def self.wrote_trackings(count)
  percent = ((count.to_f / @trackings.to_f).to_f * 100).to_i
  $stdout.flush
  print "\r#{percent}%"
end