Skip to content

Commit 92e76f0

Browse files
committed
enable_ext stackprof
1 parent 5fd9f6c commit 92e76f0

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

test/test_helper.rb

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ def time_it
7373

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

8783

8884
module DebugSlowTests
89-
def enable_extension!(...)
85+
def wrap_the_thing(name)
9086
t0 = Minitest.clock_time
91-
super
92-
puts "enable_extension! took #{Minitest.clock_time - t0} seconds"
87+
profile = StackProf.run(mode: :wall, interval: 1000) do
88+
rv = yield
89+
end
90+
puts
91+
puts "#{name} took #{Minitest.clock_time - t0} seconds"
92+
puts
93+
StackProf::Report.new(profile).print_text
94+
rv
95+
end
96+
def enable_extension!(...)
97+
wrap_the_thing(__method__) do
98+
super
99+
end
93100
end
94101

95102
def disable_extension!(...)
96-
t0 = Minitest.clock_time
97-
super
98-
puts "disable_extension! took #{Minitest.clock_time - t0} seconds"
103+
wrap_the_thing(__method__) do
104+
super
105+
end
99106
end
100107
end
101108

0 commit comments

Comments
 (0)