Class: SimpleProfiler::Reporters::Summary
- Inherits:
-
Object
- Object
- SimpleProfiler::Reporters::Summary
- Defined in:
- lib/simple_profiler/reporters/summary.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize ⇒ Summary
constructor
A new instance of Summary.
- #notify(event) ⇒ Object
- #ranking(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Summary
Returns a new instance of Summary.
7 8 9 |
# File 'lib/simple_profiler/reporters/summary.rb', line 7 def initialize @events = [] end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
5 6 7 |
# File 'lib/simple_profiler/reporters/summary.rb', line 5 def events @events end |
Instance Method Details
#notify(event) ⇒ Object
11 12 13 |
# File 'lib/simple_profiler/reporters/summary.rb', line 11 def notify(event) @events << event end |
#ranking(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/simple_profiler/reporters/summary.rb', line 15 def ranking(={}) order = .fetch(:sort_by, :total_time) # TODO: find why some events are nil, the current thought is that when the program is concurrent, the events notify may have some problems events_by_method = events.compact.group_by {|e| {klass: e.klass.to_s, method: e.method, target: e.target}} ranking = events_by_method.map do |key, values| key.merge statistics_for(values) end ranking.sort_by {|e| e[order]}.reverse end |