Skip to content

Commit

Permalink
enable_ext stackprof
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Sep 5, 2024
1 parent 5fd9f6c commit 92e76f0
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ def time_it

timeout = ENV.fetch("TEST_TIMEOUT", 10).to_i
Timeout.timeout(timeout, Timeout::Error, "Test took over #{timeout} seconds to finish") do
profile = StackProf.run(mode: :wall, interval: 1000) do
yield
end
puts
StackProf::Report.new(profile).print_text
yield
end
ensure
self.time = Minitest.clock_time - t0
Expand All @@ -86,16 +82,27 @@ def time_it


module DebugSlowTests
def enable_extension!(...)
def wrap_the_thing(name)
t0 = Minitest.clock_time
super
puts "enable_extension! took #{Minitest.clock_time - t0} seconds"
profile = StackProf.run(mode: :wall, interval: 1000) do
rv = yield
end
puts
puts "#{name} took #{Minitest.clock_time - t0} seconds"
puts
StackProf::Report.new(profile).print_text
rv
end
def enable_extension!(...)
wrap_the_thing(__method__) do
super
end
end

def disable_extension!(...)
t0 = Minitest.clock_time
super
puts "disable_extension! took #{Minitest.clock_time - t0} seconds"
wrap_the_thing(__method__) do
super
end
end
end

Expand Down

0 comments on commit 92e76f0

Please sign in to comment.