|
| 1 | +# Adapted from |
| 2 | +# https://github.com/kul-forbes/ProximalOperators.jl/tree/master/benchmark |
| 3 | +using ArgParse |
| 4 | +using PkgBenchmark |
| 5 | +using BenchmarkCI: displayjudgement, printresultmd, CIResult |
| 6 | +using Markdown |
| 7 | + |
| 8 | +function markdown_report(judgement) |
| 9 | + md = sprint(printresultmd, CIResult(judgement = judgement)) |
| 10 | + md = replace(md, ":x:" => "❌") |
| 11 | + md = replace(md, ":white_check_mark:" => "✅") |
| 12 | + return md |
| 13 | +end |
| 14 | + |
| 15 | +function parse_commandline() |
| 16 | + s = ArgParseSettings() |
| 17 | + |
| 18 | + @add_arg_table! s begin |
| 19 | + "--target" |
| 20 | + help = "the branch/commit/tag to use as target" |
| 21 | + default = "HEAD" |
| 22 | + "--baseline" |
| 23 | + help = "the branch/commit/tag to use as baseline" |
| 24 | + default = "master" |
| 25 | + "--retune" |
| 26 | + help = "force re-tuning (ignore existing tuning data)" |
| 27 | + action = :store_true |
| 28 | + end |
| 29 | + |
| 30 | + return parse_args(s) |
| 31 | +end |
| 32 | + |
| 33 | +function main() |
| 34 | + parsed_args = parse_commandline() |
| 35 | + |
| 36 | + mkconfig(; kwargs...) = |
| 37 | + BenchmarkConfig( |
| 38 | + env = Dict( |
| 39 | + "JULIA_NUM_THREADS" => get(ENV, "JULIA_NUM_THREADS", "1"), |
| 40 | + ); |
| 41 | + kwargs... |
| 42 | + ) |
| 43 | + |
| 44 | + target = parsed_args["target"] |
| 45 | + group_target = benchmarkpkg( |
| 46 | + dirname(@__DIR__), |
| 47 | + mkconfig(id = target), |
| 48 | + resultfile = joinpath(@__DIR__, "result-$(target).json"), |
| 49 | + retune = parsed_args["retune"], |
| 50 | + ) |
| 51 | + |
| 52 | + baseline = parsed_args["baseline"] |
| 53 | + group_baseline = benchmarkpkg( |
| 54 | + dirname(@__DIR__), |
| 55 | + mkconfig(id = baseline), |
| 56 | + resultfile = joinpath(@__DIR__, "result-$(baseline).json"), |
| 57 | + ) |
| 58 | + |
| 59 | + judgement = judge(group_target, group_baseline) |
| 60 | + report_md = markdown_report(judgement) |
| 61 | + write(joinpath(@__DIR__, "report.md"), report_md) |
| 62 | + display(Markdown.parse(report_md)) |
| 63 | +end |
| 64 | + |
| 65 | +main() |
0 commit comments