Module: HeapScope::Overhead
- Defined in:
- lib/heapscope/paths.rb
Overview
Self-overhead profiler to avoid HeapScope dominating the workload.
Class Method Summary collapse
Class Method Details
.measure_snapshot(mode: :lightweight, runs: 3) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/heapscope/paths.rb', line 49 def measure_snapshot(mode: :lightweight, runs: 3) times = runs.times.map do t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) snap = HeapScope.snapshot(mode: mode, max_objects: 50_000) elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0 { seconds: elapsed, duration_ms: snap.duration_ms, classes: snap.class_stats.size } end { mode: mode, runs: times, avg_seconds: (times.sum { |t| t[:seconds] } / times.size).round(4), note: "HeapScope overhead for this mode on this machine." } end |