Skip to content

Commit bdacf47

Browse files
committed
add benchmarks compatible with PkgBenchmark
1 parent 6f0c43c commit bdacf47

File tree

5 files changed

+104
-1
lines changed

5 files changed

+104
-1
lines changed

.github/workflows/benchmark.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Benchmark
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
permissions:
7+
pull-requests: write # action needs to post a comment
8+
9+
jobs:
10+
benchmark:
11+
name: Julia ${{ matrix.version }} - ${{ matrix.platform.os }} - ${{ matrix.platform.arch }} - ${{ github.event_name }}
12+
runs-on: ${{ matrix.platform.os }}
13+
strategy:
14+
matrix:
15+
platform:
16+
- os: ubuntu-latest
17+
arch: x64
18+
- os: ubuntu-24.04-arm
19+
arch: aarch64
20+
version:
21+
- '1'
22+
steps:
23+
- uses: MilesCranmer/AirspeedVelocity.jl@action-v1
24+
with:
25+
julia-version: ${{ matrix.version }}
26+
job-summary: 'true'

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Manifest.toml
2828

2929
# Test data files and benchmarking
3030
jetsavetest*.dat
31-
benchmark/*
3231

3332
# Misc files
3433
.DS_Store

benchmark/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196"
4+
5+
[sources]
6+
JetReconstruction = {path = ".."}

benchmark/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Mini-benchmarks for JetReconstruction
2+
3+
The benchmarks can be follow the standard [`PkgBenchmark.jl`](https://juliaci.github.io/PkgBenchmark.jl/stable/) structure. Can be run locally with you favourite `PkgBenchmark.jl`-compatible tool.
4+
5+
```sh
6+
julia --project=benchmark benchmark/benchmarks.jl
7+
```

benchmark/benchmarks.jl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using BenchmarkTools
2+
using JetReconstruction
3+
4+
const events_file_pp = joinpath(@__DIR__, "..", "test", "data", "events.pp13TeV.hepmc3.gz")
5+
const events_file_ee = joinpath(@__DIR__, "..", "test", "data", "events.eeH.hepmc3.gz")
6+
7+
const pp_events = JetReconstruction.read_final_state_particles(events_file_pp,
8+
T = PseudoJet)
9+
const ee_events = JetReconstruction.read_final_state_particles(events_file_ee, T = EEJet)
10+
11+
function jet_reconstruct_harness(events; algorithm, strategy, power, distance,
12+
recombine = RecombinationMethods[RecombinationScheme.EScheme],
13+
ptmin::Real = 5.0, dcut = nothing, njets = nothing,)
14+
for event in events
15+
cs = jet_reconstruct(event; R = distance, p = power, algorithm = algorithm,
16+
strategy = strategy, recombine...)
17+
if !isnothing(njets)
18+
finaljets = exclusive_jets(cs; njets = njets)
19+
elseif !isnothing(dcut)
20+
finaljets = exclusive_jets(cs; dcut = dcut)
21+
else
22+
finaljets = inclusive_jets(cs; ptmin = ptmin)
23+
end
24+
end
25+
end
26+
27+
const SUITE = BenchmarkGroup()
28+
SUITE["jet_reconstruction"] = BenchmarkGroup(["reconstruction"])
29+
30+
## pp events
31+
for stg in [RecoStrategy.N2Plain, RecoStrategy.N2Tiled]
32+
strategy_name = "$(stg)"
33+
SUITE["jet_reconstruction"][strategy_name] = BenchmarkGroup(["pp", strategy_name])
34+
for alg in [JetAlgorithm.AntiKt, JetAlgorithm.CA, JetAlgorithm.Kt]
35+
for distance in [0.4]
36+
power = JetReconstruction.algorithm2power[alg]
37+
SUITE["jet_reconstruction"][strategy_name]["Alg=$alg, R=$distance"] = @benchmarkable jet_reconstruct_harness($pp_events;
38+
algorithm = $alg,
39+
strategy = $stg,
40+
power = $power,
41+
distance = $distance,
42+
ptmin = 5.0) evals=1 samples=32
43+
end
44+
end
45+
end
46+
47+
## ee events
48+
SUITE["jet_reconstruction"]["ee"] = BenchmarkGroup(["ee"])
49+
for alg in [JetAlgorithm.Durham]
50+
for distance in [0.4]
51+
power = -1
52+
SUITE["jet_reconstruction"]["ee"]["Alg=$alg, R=$distance"] = @benchmarkable jet_reconstruct_harness($ee_events;
53+
algorithm = $alg,
54+
strategy = $RecoStrategy.Best,
55+
power = $power,
56+
distance = $distance,
57+
ptmin = 5.0) evals=1 samples=32
58+
end
59+
end
60+
61+
if abspath(PROGRAM_FILE) == @__FILE__
62+
@info "Running benchmark suite"
63+
results = run(SUITE, verbose = true)
64+
@info results
65+
end

0 commit comments

Comments
 (0)