We're currently debugging the very long test/CI time of SolidStateDetectors.jl. Since it's a numerical package it has to run a lot of calculations during CI to check if it's working correctly, but we've definitely reached a point where we need to cut it down at least a bit, and so we need a clear picture of where most of the test time is spent. TimerOutputs is so handy here (thanks @KristofferC ! ).
I ended up writing a macro
testtimer() = get_timer("_default_testtimer_")
macro timed_testset(title, body)
quote
tmr = testtimer()
_title = $(esc(title))
@timeit tmr "$_title" begin
@testset "$_title" begin
$(esc(body))
end
end
end
end
So one can simple replace @testset by @timed_testset in the test code and get something like
@timed_testset "a" begin
@timed_testset "a.1" begin
@test (sleep(1); true)
end
@timed_testset "a.2" begin
@test (sleep(1); true)
end
end
@timed_testset "b" begin
@timed_testset "b.1" begin
@test (sleep(1); true)
end
@timed_testset "b.2" begin
@test (sleep(1); true)
end
end
and then just insert display(testtimer()) at the end of "runtests.jl" to add the result
We're currently debugging the very long test/CI time of SolidStateDetectors.jl. Since it's a numerical package it has to run a lot of calculations during CI to check if it's working correctly, but we've definitely reached a point where we need to cut it down at least a bit, and so we need a clear picture of where most of the test time is spent. TimerOutputs is so handy here (thanks @KristofferC ! ).
I ended up writing a macro
So one can simple replace
@testset
by@timed_testset
in the test code and get something likeand then just insert
display(testtimer())
at the end of "runtests.jl" to add the resultto the CI output. I think this could be very useful in general - could we add such a macro to TimerOutputs.jl (I could prep a PR)?