Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Manifest.toml

# Test data files and benchmarking
jetsavetest*.dat
benchmark/*
benchmark/*.json

# Misc files
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ JSON = "0.21"
Logging = "1.9"
LoopVectorization = "0.12.170"
LorentzVectorHEP = "0.1.6"
Makie = "0.20, 0.21, 0.22"
Makie = "0.20, 0.21, 0.22, 0.24"
MuladdMacro = "0.2.4"
StructArrays = "0.6.18, 0.7"
Test = "1.9"
Expand Down
6 changes: 6 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196"

[sources]
JetReconstruction = {path = ".."}
7 changes: 7 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Mini-benchmarks for JetReconstruction

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.

```sh
julia --project=benchmark benchmark/benchmarks.jl
```
69 changes: 69 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using BenchmarkTools
using JetReconstruction

const events_file_pp = joinpath(@__DIR__, "..", "test", "data", "events.pp13TeV.hepmc3.gz")
const events_file_ee = joinpath(@__DIR__, "..", "test", "data", "events.eeH.hepmc3.gz")

const pp_events = JetReconstruction.read_final_state_particles(events_file_pp,
T = PseudoJet)
const ee_events = JetReconstruction.read_final_state_particles(events_file_ee, T = EEJet)

function jet_reconstruct_harness(events; algorithm, strategy, power, distance,
recombine = RecombinationMethods[RecombinationScheme.EScheme],
ptmin::Real = 5.0, dcut = nothing, njets = nothing,)
for event in events
cs = jet_reconstruct(event; R = distance, p = power, algorithm = algorithm,
strategy = strategy, recombine...)
if !isnothing(njets)
finaljets = exclusive_jets(cs; njets = njets)
elseif !isnothing(dcut)
finaljets = exclusive_jets(cs; dcut = dcut)
else
finaljets = inclusive_jets(cs; ptmin = ptmin)
end
end
end

const SUITE = BenchmarkGroup()
SUITE["jet_reconstruction"] = BenchmarkGroup(["reconstruction"])

## pp events
for stg in [RecoStrategy.N2Plain, RecoStrategy.N2Tiled]
strategy_name = "$(stg)"
SUITE["jet_reconstruction"][strategy_name] = BenchmarkGroup(["pp", strategy_name])
for alg in [JetAlgorithm.AntiKt, JetAlgorithm.CA, JetAlgorithm.Kt]
for distance in [0.4]
power = JetReconstruction.algorithm2power[alg]
SUITE["jet_reconstruction"][strategy_name]["Alg=$alg, R=$distance"] = @benchmarkable jet_reconstruct_harness($pp_events;
algorithm = $alg,
strategy = $stg,
power = $power,
distance = $distance,
ptmin = 5.0) evals=1 samples=32
end
end
end

## ee events
SUITE["jet_reconstruction"]["ee"] = BenchmarkGroup(["ee"])
for alg in [JetAlgorithm.Durham]
for distance in [0.4]
power = -1
SUITE["jet_reconstruction"]["ee"]["Alg=$alg, R=$distance"] = @benchmarkable jet_reconstruct_harness($ee_events;
algorithm = $alg,
strategy = $RecoStrategy.Best,
power = $power,
distance = $distance,
ptmin = 5.0) evals=1 samples=32
end
end

if abspath(PROGRAM_FILE) == @__FILE__
@info "Running benchmark suite"
results = run(SUITE, verbose = true)
@info results
if !isempty(ARGS)
BenchmarkTools.save(ARGS[1], median(results))
@info "Results saved to $(ARGS[1])"
end
end