Class: QAT::Reporter::Times
- Inherits:
-
Object
- Object
- QAT::Reporter::Times
- Extended by:
- Helpers::TimeFormat
- Includes:
- Logger
- Defined in:
- lib/qat/reporter/times.rb,
lib/qat/reporter/times/report.rb,
lib/qat/reporter/times/helpers.rb
Overview
namespace for time report measures
Defined Under Namespace
Modules: Report Classes: NoEndtTimeError, NoLabelInConfig, NoStartTimeError
Constant Summary collapse
- Helpers =
Namespace for Times Helpers
QAT::Reporter::Helpers::TimeFormat
Class Method Summary collapse
-
.browser_name=(name) ⇒ String
Defines browser name.
-
.browser_version=(version) ⇒ String
Defines browser version.
-
.generate_time_report(test_id) ⇒ String
Generates the time report of a test using the names stored in QAT.
-
.get_duration(name) ⇒ Float
Gets duration execution time.
-
.get_execution_time(name) ⇒ Time
Gets formatted execution time.
-
.has_times? ⇒ Boolean
Verifies if QAT Storage has times.
-
.measure(name) { ... } ⇒ String
Measures the execution time of a block of code.
-
.os_name=(name) ⇒ String
Defines OS name.
-
.os_version=(version) ⇒ String
Defines OS version.
-
.start(loading_name, time = Time.now) ⇒ Time
Starts a time measure.
-
.stop(measure_key, time = Time.now) ⇒ Time/Nil
Stops a time measure.
-
.stop!(measure_key, time = Time.now) ⇒ Time
Stops a time measure.
Methods included from Helpers::TimeFormat
Class Method Details
.browser_name=(name) ⇒ String
Defines browser name
86 87 88 |
# File 'lib/qat/reporter/times.rb', line 86 def self.browser_name=(name) QAT.store_permanently :browser_name, name end |
.browser_version=(version) ⇒ String
Defines browser version
93 94 95 |
# File 'lib/qat/reporter/times.rb', line 93 def self.browser_version=(version) QAT.store_permanently :browser_version, version end |
.generate_time_report(test_id) ⇒ String
Generates the time report of a test using the names stored in QAT
100 101 102 103 104 105 106 107 108 |
# File 'lib/qat/reporter/times.rb', line 100 def self.generate_time_report(test_id) measures = get_measures measures.each do |id, measure| log.info build_measure(test_id, id, measure) end measures end |
.get_duration(name) ⇒ Float
Gets duration execution time
120 121 122 123 124 |
# File 'lib/qat/reporter/times.rb', line 120 def self.get_duration(name) end_key = "#{name}_end".to_sym QAT[end_key] ||= Time.now QAT[end_key].to_f - QAT["#{name}_start".to_sym].to_f end |
.get_execution_time(name) ⇒ Time
Gets formatted execution time
113 114 115 |
# File 'lib/qat/reporter/times.rb', line 113 def self.get_execution_time(name) human_formatted_time(get_duration(name)) end |
.has_times? ⇒ Boolean
Verifies if QAT Storage has times
128 129 130 |
# File 'lib/qat/reporter/times.rb', line 128 def self.has_times? QAT::Core.instance.instance_variable_get(:@storage).keys.any? {|key| key.match(/_start$/)} end |
.measure(name) { ... } ⇒ String
Measures the execution time of a block of code
60 61 62 63 64 65 66 67 |
# File 'lib/qat/reporter/times.rb', line 60 def self.measure(name) raise(ArgumentError, 'No block given') unless block_given? start(name) result = yield stop(name) log.debug "Total time at #{name}: #{get_execution_time(name)}" result end |
.os_name=(name) ⇒ String
Defines OS name
72 73 74 |
# File 'lib/qat/reporter/times.rb', line 72 def self.os_name=(name) QAT.store_permanently :os_name, name end |
.os_version=(version) ⇒ String
Defines OS version
79 80 81 |
# File 'lib/qat/reporter/times.rb', line 79 def self.os_version=(version) QAT.store_permanently :os_version, version end |
.start(loading_name, time = Time.now) ⇒ Time
Starts a time measure
18 19 20 21 22 23 24 25 |
# File 'lib/qat/reporter/times.rb', line 18 def self.start(loading_name, time = Time.now) if QAT::Core.instance.instance_variable_get(:@storage).key?("#{loading_name}_start".to_sym) log.warn "Time measurement '#{measure_description(loading_name) rescue loading_name}' already exists..." nil else QAT.store "#{loading_name}_start".to_sym, time end end |
.stop(measure_key, time = Time.now) ⇒ Time/Nil
Stops a time measure
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/qat/reporter/times.rb', line 31 def self.stop(measure_key, time = Time.now) if QAT::Core.instance.instance_variable_get(:@storage).key?("#{measure_key}_start".to_sym) if QAT::Core.instance.instance_variable_get(:@storage).key?("#{measure_key}_end".to_sym) log.warn "Time measurement '#{measure_description(measure_key) rescue measure_key}' already exists..." nil else QAT.store "#{measure_key}_end".to_sym, time end else log.warn "No Start time was found for '#{measure_description(measure_key) rescue measure_key}'!" nil end end |
.stop!(measure_key, time = Time.now) ⇒ Time
Stops a time measure
50 51 52 53 54 |
# File 'lib/qat/reporter/times.rb', line 50 def self.stop!(measure_key, time = Time.now) stop_time = self.stop(measure_key, time) raise NoStartTimeError.new 'No Start time was found!' unless stop_time stop_time end |