Class: Stopwatch
Instance Attribute Summary collapse
-
#roundvals ⇒ Object
readonly
Returns the value of attribute roundvals.
-
#t1 ⇒ Object
readonly
Returns the value of attribute t1.
-
#t2 ⇒ Object
readonly
Returns the value of attribute t2.
Instance Method Summary collapse
Methods included from NumTools
define_component, #random_between
Instance Attribute Details
#roundvals ⇒ Object (readonly)
Returns the value of attribute roundvals.
32 33 34 |
# File 'lib/walltime.rb', line 32 def roundvals @roundvals end |
#t1 ⇒ Object (readonly)
Returns the value of attribute t1.
32 33 34 |
# File 'lib/walltime.rb', line 32 def t1 @t1 end |
#t2 ⇒ Object (readonly)
Returns the value of attribute t2.
32 33 34 |
# File 'lib/walltime.rb', line 32 def t2 @t2 end |
Instance Method Details
#print_stats ⇒ Object
56 57 58 59 |
# File 'lib/walltime.rb', line 56 def print_stats round = round_to(@t2 - @t1, 2) puts "Start: #{Time.at(@t1)} Finish: #{Time.at(@t2)} Total time: #{round}" end |
#record(round) ⇒ Object
52 53 54 |
# File 'lib/walltime.rb', line 52 def record(round) @roundvals << round end |
#watch(method) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/walltime.rb', line 61 def watch(method) if method == "start" @t1 = elsif method == "stop" @t2 = intervalh end end |