Class: AppTester::Timer Abstract
- Inherits:
-
Object
- Object
- AppTester::Timer
- Defined in:
- lib/app-tester/timer.rb
Overview
This class is abstract.
Benchmark helper class
Instance Method Summary collapse
-
#initialize(message = nil, threshold = nil, method = nil, *args) { ... } ⇒ Timer
constructor
Created a new timer object.
Constructor Details
#initialize(message = nil, threshold = nil, method = nil, *args) { ... } ⇒ Timer
Created a new timer object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/app-tester/timer.rb', line 20 def initialize(=nil, threshold=nil, method=nil, *args) beginning_time = Time.now if block_given? yield else self.send(method, args) end end_time = Time.now time_passed = ((end_time - beginning_time)*1000).round(3) = "" unless threshold.nil? printf "#{AppTester::Utils::Strings::WARNING} " if time_passed.to_f > threshold.to_f = " (threshold: #{threshold} ms)" end = "to #{}," if puts "Time elapsed #{} #{time_passed} milliseconds#{}" puts "" end |