comparison benchmark/benchmark_utils.jl @ 1594:d68d02dd882f feature/boundary_conditions

Merge with default
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sat, 25 May 2024 16:07:10 -0700
parents 5193e6cd6c6a
children 237b980ffb91 471a948cd2b2
comparison
equal deleted inserted replaced
1591:615eeb6e662e 1594:d68d02dd882f
21 * If both `target` and `baseline` is set those revision are compared. 21 * If both `target` and `baseline` is set those revision are compared.
22 22
23 For control over what happens to the benchmark result datastructure see the 23 For control over what happens to the benchmark result datastructure see the
24 different methods of [`run_benchmark`](@ref) 24 different methods of [`run_benchmark`](@ref)
25 """ 25 """
26 function main(;rev=nothing, target=nothing, baseline=nothing , kwargs...) 26 function main(;rev=nothing, target=nothing, baseline=nothing, name=nothing, kwargs...)
27 if !isnothing(rev) 27 if !isnothing(rev)
28 r = run_benchmark(rev; kwargs...) 28 r = run_benchmark(rev; kwargs...)
29 elseif !isnothing(baseline) 29 elseif !isnothing(baseline)
30 if isnothing(target) 30 if isnothing(target)
31 r = compare_benchmarks(baseline; kwargs...) 31 r = compare_benchmarks(baseline; kwargs...)
35 else 35 else
36 # Neither rev, or baseline were set => Run on current working directory. 36 # Neither rev, or baseline were set => Run on current working directory.
37 r = run_benchmark(;kwargs...) 37 r = run_benchmark(;kwargs...)
38 end 38 end
39 39
40 file_path = write_result_html(r) 40 file_path = write_result_html(r; name)
41 open_in_default_browser(file_path) 41 open_in_default_browser(file_path)
42 end 42 end
43 43
44 44
45 """ 45 """
135 135
136 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HH:MM:SS") 136 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HH:MM:SS")
137 Mustache.render(io, template, Dict("title"=>dt, "content"=>content)) 137 Mustache.render(io, template, Dict("title"=>dt, "content"=>content))
138 end 138 end
139 139
140 function write_result_html(r) 140 function write_result_html(r; name=nothing)
141 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HHMMSS") 141 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HHMMSS")
142 file_path = joinpath(results_dir, dt*".html") 142
143 if isnothing(name)
144 file_path = joinpath(results_dir, dt*".html")
145 else
146 file_path = joinpath(results_dir, dt*" "*name*".html")
147 end
143 148
144 open(file_path, "w") do io 149 open(file_path, "w") do io
145 write_result_html(io, r) 150 write_result_html(io, r)
146 end 151 end
147 152