Skip to content

Instantly share code, notes, and snippets.

@dalehamel
Created April 9, 2019 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalehamel/74dac2ec39a97e71ffde3f229000179a to your computer and use it in GitHub Desktop.
Save dalehamel/74dac2ec39a97e71ffde3f229000179a to your computer and use it in GitHub Desktop.
probe test
#!/usr/bin/env ruby
require 'ruby-static-tracing'
DEBUG = ENV['DEBUG']
t = StaticTracing::Tracepoint.new('global', 'hello_nsec', Integer, String)
p = StaticTracing::Provider.fetch(t.provider)
p.enable
l = StaticTracing.nsec
while true do
i = StaticTracing.nsec
puts "iteration: #{i-l} ns" if DEBUG
l = i
if t.enabled?
d = StaticTracing.nsec
puts "enabled: #{d-i} ns" if DEBUG
t.fire(StaticTracing.nsec, "Hello world")
f = StaticTracing.nsec
puts "fire: #{f-i} ns" if DEBUG
puts StaticTracing.nsec
puts "Probe fired!"
else
puts "Not enabled"
end
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment