|
1 | | -ROOTPATH = joinpath(@__DIR__, "../..") |
| 1 | +ROOTPATH = abspath(joinpath(@__DIR__, "../..")) |
2 | 2 | import Pkg |
3 | 3 | Pkg.activate(@__DIR__) |
4 | 4 | if !isfile(joinpath(@__DIR__, "Manifest.toml")) |
5 | 5 | Pkg.develop(Pkg.PackageSpec(; path=ROOTPATH)) |
6 | 6 | Pkg.instantiate() |
7 | 7 | end |
8 | 8 |
|
9 | | -using BenchmarkCI |
10 | | - |
| 9 | +import BenchmarkCI |
11 | 10 | import LibGit2 |
12 | | -repo = mktempdir(mktempdir()) # TestItemRunner needs access to parent directory as well. |
13 | | -LibGit2.clone("https://github.com/epolack/DFTK-testproblems", repo) |
14 | 11 |
|
15 | | -# Workaround to be able to benchmark releases before the use of PkgBenchmark. |
16 | | -script = tempname(repo) * ".jl" |
17 | | -benchpath = joinpath(ROOTPATH, "benchmark", "humongous", "benchmarks.jl") |
18 | | -project = dirname(benchpath) |
19 | | -cp(benchpath, script) |
| 12 | +""" |
| 13 | +Launch with |
| 14 | +```julia |
| 15 | +julia --project=benchmark/humongous -e ' |
| 16 | + include("benchmark/humongous/run.jl") |
| 17 | + run_benchmark()' |
| 18 | +``` |
| 19 | +""" |
| 20 | +function run_benchmark(; retune=false, baseline="origin/master", target="HEAD", |
| 21 | + script=nothing) |
| 22 | + mktempdir(mktempdir()) do repo_dir # TestItemRunner needs access to parent directory as well. |
| 23 | + project = joinpath(ROOTPATH, "benchmark", "humongous") |
| 24 | + # Workaround to be able to benchmark releases before the use of PkgBenchmark. |
| 25 | + # WARN: In this case, we need PkgBenchmark to be installed globally. |
| 26 | + if isnothing(script) |
| 27 | + # We run the default benchmark. |
| 28 | + script = joinpath(project, "benchmarks.jl") |
| 29 | + else |
| 30 | + occursin(ROOTPATH, abspath(script)) && |
| 31 | + error("Script should be outside the repository.") |
| 32 | + end |
| 33 | + script_copy = joinpath(repo_dir, "benchmarks.jl") |
| 34 | + cp(script, script_copy) |
| 35 | + |
| 36 | + LibGit2.clone("https://github.com/epolack/DFTK-testproblems", |
| 37 | + joinpath(repo_dir, "test")) |
20 | 38 |
|
21 | | -BenchmarkCI.judge(; retune=true, script, project) |
| 39 | + BenchmarkCI.judge(; baseline, target, retune, script=script_copy, project) |
22 | 40 |
|
23 | | -BenchmarkCI.displayjudgement() |
| 41 | + BenchmarkCI.displayjudgement() |
| 42 | + end |
| 43 | +end |
0 commit comments