Module: SeleniumStatistics
- Extended by:
- SeleniumStatistics
- Included in:
- SeleniumStatistics
- Defined in:
- lib/selenium_statistics/version.rb,
lib/selenium_statistics/statistics.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#executions ⇒ Object
readonly
Returns the value of attribute executions.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
Instance Attribute Details
#executions ⇒ Object (readonly)
Returns the value of attribute executions.
5 6 7 |
# File 'lib/selenium_statistics/statistics.rb', line 5 def executions @executions end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/selenium_statistics/statistics.rb', line 5 def time @time end |
Instance Method Details
#print_results(sort = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/selenium_statistics/statistics.rb', line 45 def print_results(sort=nil) str = "Executed a total of #{executions} commands in #{time.round(1)} seconds\n" results(sort).each do |k,v| str << "\t#{k}: \n\t\t\t#{v[:count]} executions;" str << "\ttotal of #{v[:time].round(1)} sec;" str << "\tavg of #{v[:average].round(3)} sec/cmd;" str << "\t#{(100*v[:average_total]).round(2)}% of total\n" end puts str end |
#reset! ⇒ Object
58 59 60 61 62 63 |
# File 'lib/selenium_statistics/statistics.rb', line 58 def reset! @commands = {} @time = 0 @executions = 0 @test_start = Time.now end |
#results(sort = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/selenium_statistics/statistics.rb', line 37 def results(sort=nil) sort ||= :count @test_time = Time.now - @test_start @commands.each { |_k, v| v[:average_total] = v[:time]/@test_time} @commands.sort_by { |_k, v| v[sort] }.reverse.to_h end |