Class: Hone::Profilers::Vernier
- Includes:
- MethodMatching
- Defined in:
- lib/hone/profilers/vernier.rb
Instance Method Summary collapse
-
#cpu_percent_for(method_info) ⇒ Object
Returns CPU percentage for a method (0.0-100.0) method_info can be a Hash with :name and/or :file keys, or a String method name.
-
#hotspots(threshold: 1.0) ⇒ Object
Returns array of HotspotInfo for frames above threshold.
-
#initialize(profile_path) ⇒ Vernier
constructor
A new instance of Vernier.
Constructor Details
#initialize(profile_path) ⇒ Vernier
Returns a new instance of Vernier.
10 11 12 13 14 |
# File 'lib/hone/profilers/vernier.rb', line 10 def initialize(profile_path) super parse_profile end |
Instance Method Details
#cpu_percent_for(method_info) ⇒ Object
Returns CPU percentage for a method (0.0-100.0) method_info can be a Hash with :name and/or :file keys, or a String method name
18 19 20 21 22 23 |
# File 'lib/hone/profilers/vernier.rb', line 18 def cpu_percent_for(method_info) frame = find_matching_frame(method_info) return nil unless frame frame[:cpu_percent] end |
#hotspots(threshold: 1.0) ⇒ Object
Returns array of HotspotInfo for frames above threshold
26 27 28 29 30 31 |
# File 'lib/hone/profilers/vernier.rb', line 26 def hotspots(threshold: 1.0) @frames .select { |frame| frame[:cpu_percent] >= threshold } .sort_by { |frame| -frame[:cpu_percent] } .map { |frame| build_hotspot_info(frame) } end |