diff --git a/.gitignore b/.gitignore index d1458d2d..6a84dfcd 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ Manifest.toml # Test data files and benchmarking jetsavetest*.dat -benchmark/* +benchmark/*.json # Misc files .DS_Store diff --git a/Project.toml b/Project.toml index 51e5e2a4..cb031c4e 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/benchmark/Project.toml b/benchmark/Project.toml new file mode 100644 index 00000000..e8a3ff0c --- /dev/null +++ b/benchmark/Project.toml @@ -0,0 +1,6 @@ +[deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196" + +[sources] +JetReconstruction = {path = ".."} diff --git a/benchmark/README.md b/benchmark/README.md new file mode 100644 index 00000000..d02d73b2 --- /dev/null +++ b/benchmark/README.md @@ -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 +``` \ No newline at end of file diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 00000000..c908c4c9 --- /dev/null +++ b/benchmark/benchmarks.jl @@ -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