Project

perf

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A gem to use Linux perf easily
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Perf

Use Linux perf for some region of Ruby code easily.

Usage

Run as root to use perf. Otherwise it just executes a given block.

perf record

require 'erb'
require 'perf'

def bench
  ERB.new('<%= 1 %>').result
end

10000.times { bench }
if RubyVM::MJIT.enabled?
  RubyVM::MJIT.pause
end

Perf.record(count: 5000, call_graph: :dwarf) do
  50000.times { bench }
end

perf stat

Perf.stat(event: %w[cycles instructions branches branch-misses]) do
  50000.times { bench }
end

License

The gem is available as open source under the terms of the MIT License.