Class: ProductionBreakpoints::Breakpoints::Latency

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby-production-breakpoints/breakpoints/latency.rb

Overview

Exposes nanosecond the latency of executing the selected lines

Constant Summary collapse

TRACEPOINT_TYPES =

FIXME: refactor a bunch of these idioms into Base

[Integer].freeze

Instance Attribute Summary

Attributes inherited from Base

#name, #provider_name, #tracepoint

Instance Method Summary collapse

Methods inherited from Base

#initialize, #install, #load, #resume, #uninstall, #unload

Constructor Details

This class inherits a constructor from ProductionBreakpoints::Breakpoints::Base

Instance Method Details

#handle(caller_binding, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/ruby-production-breakpoints/breakpoints/latency.rb', line 9

def handle(caller_binding, &block)
  return super(caller_binding, &block) unless @tracepoint.enabled?

  start_time = StaticTracing.nsec
  val = super(caller_binding, &block)
  duration = StaticTracing.nsec - start_time
  @tracepoint.fire(duration)
  resume(caller_binding, &block) || val
end