I added a performance test to my package KiteModels.jl: Benchmark simplify operation by ufechner7 · Pull Request #250 · OpenSourceAWE/KiteModels.jl · GitHub .
If you run the script, you get an output like:
julia> include("test/bench_simplify.jl")
[ Info: Simplifying the system
[ Info: Simplify took 37.283457024 seconds
I want a unit test that fails in case of a performance regression of a commit of 20% or more. How can I achieve that?
The absolute time depends on:
the computer it runs on
the load on the computer
If it runs on a laptop, it depends on the question of whether it is connected to power or running on battery
etc
How can I catch regressions independent of the hardware on which the code is running?
Ideas:
Create a dictionary with reference values per computer
Disable the test if the computer is running on battery (how can I detect that?)
Scale the time with the clock frequency of the core on which the main thread is running (how can I detect that?)
Disable the test if the system load is too high (how can I detect that?)
adienes
September 22, 2025, 5:42pm
2
I once did something like this
cpu_model_raw = getproperty(first(Sys.cpu_info()), :model)
cpu_model = lowercase(replace(cpu_model_raw, r"\(.*?\)" => "", ' '=>'-'))
cpu_name = lowercase(replace(Sys.CPU_NAME, '_'=>'-'))
reference_benchmark = "benchmark/profile_$(cpu_name)_$cpu_model.json"
it won’t get the battery vs power stuff, or system load, but at least let me partition by cpu
1 Like
juliohm
September 22, 2025, 5:55pm
3
Take a look into AirSpeedVelocity.jl. You can adapt the benchmarks and GitHub Action we have in Meshes.jl for example. We did setup the action so that every PR triggers benchmark results as comments:
master
← ray-triangle-intersection
opened 05:40PM - 10 Jul 25 UTC
I refactored the code to follow the exact same steps of the non-culling branch d… escribed in the Möller, T. & Trumbore, B. 1997 paper. I understand that this branch will compute the correct intersection even when triangles are back-faces.
The new implementation avoids unnecessary intermediate computations like the variable `T` that is only computed after the determinant check. It also follows the notation of the paper more closely to facilitate future maintenance.
3 Likes
But how do you handle the fact that the results are hardware dependant?
juliohm
September 22, 2025, 6:03pm
5
The benchmarks are run on the same remote machines. But I would double check the exact infrastructure that AirSpeedVelocity.jl provides.
1 Like
A simple way I think is to benchmark against a reference benchmark which contains simple code which does not change. Like some king of stupid loop.