Skip to content

Commit

Permalink
Add benchmark file
Browse files Browse the repository at this point in the history
  • Loading branch information
badosu committed Jun 20, 2013
1 parent 479b000 commit 25629da
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions examples/benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'benchmark'

unless Object.const_defined? :BindingOfCaller
$:.unshift File.expand_path '../../lib', __FILE__
require 'binding_of_caller'
require 'binding_of_caller/version'
end


n = 250000

Benchmark.bm(10) do |x|
x.report("#of_caller") do
1.upto(n) do
1.times do
1.times do
binding.of_caller(2)
binding.of_caller(1)
end
end
end
end

x.report("#frame_count") do
1.upto(n) do
1.times do
1.times do
binding.frame_count
end
end
end
end

x.report("#callers") do
1.upto(n) do
1.times do
1.times do
binding.callers
end
end
end
end

x.report("#frame_description") do
1.upto(n) do
1.times do
1.times do
binding.of_caller(1).frame_description
end
end
end
end

x.report("#frame_type") do
1.upto(n) do
1.times do
1.times do
binding.of_caller(1).frame_type
end
end
end
end
end

0 comments on commit 25629da

Please sign in to comment.