Class: TinyProfiler
- Inherits:
-
Object
- Object
- TinyProfiler
- Includes:
- Singleton
- Defined in:
- lib/tiny_profiler.rb,
lib/tiny_profiler/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Attribute Summary collapse
-
#intervals ⇒ Object
Returns the value of attribute intervals.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#times ⇒ Object
Returns the value of attribute times.
Instance Method Summary collapse
Instance Attribute Details
#intervals ⇒ Object
Returns the value of attribute intervals.
9 10 11 |
# File 'lib/tiny_profiler.rb', line 9 def intervals @intervals end |
#start_time ⇒ Object
Returns the value of attribute start_time.
8 9 10 |
# File 'lib/tiny_profiler.rb', line 8 def start_time @start_time end |
#times ⇒ Object
Returns the value of attribute times.
10 11 12 |
# File 'lib/tiny_profiler.rb', line 10 def times @times end |
Instance Method Details
#finished ⇒ Object
20 21 22 23 24 |
# File 'lib/tiny_profiler.rb', line 20 def finished interval = Time.now - @start_time @times["total"] = interval return @times end |
#interval(name) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/tiny_profiler.rb', line 12 def interval(name) now = Time.now interval = now - @intervals.last @intervals << now @times[name] = interval p "#{name}: #{interval}" end |
#reset ⇒ Object
32 33 34 |
# File 'lib/tiny_profiler.rb', line 32 def reset start end |
#start ⇒ Object
26 27 28 29 30 |
# File 'lib/tiny_profiler.rb', line 26 def start @start_time = Time.now @intervals = [@start_time] @times = {} end |