@@ -16,7 +16,7 @@ using LorentzVectorHEP
1616using JetReconstruction
1717
1818# Backends for the jet reconstruction
19- @enumx T= Backend Backends Julia FastJet
19+ @enumx T= Backend Backends Julia FastJet CJetReconstruction
2020const AllBackends = [String (Symbol (x)) for x in instances (Backends. Backend)]
2121
2222# Parsing for Enum types
@@ -118,13 +118,14 @@ function julia_jet_process_avg_time(events::Vector{Vector{PseudoJet}};
118118 lowest_time
119119end
120120
121- function fastjet_jet_process_avg_time (input_file:: AbstractString ;
122- ptmin:: Float64 = 5.0 ,
123- distance:: Float64 = 0.4 ,
124- p:: Union{Real, Nothing} = nothing ,
125- algorithm:: JetAlgorithm.Algorithm = JetAlgorithm. AntiKt,
126- strategy:: RecoStrategy.Strategy ,
127- nsamples:: Integer = 1 )
121+ function external_benchmark_avg_time (input_file:: AbstractString ;
122+ ptmin:: Float64 = 5.0 ,
123+ distance:: Float64 = 0.4 ,
124+ p:: Union{Real, Nothing} = nothing ,
125+ algorithm:: JetAlgorithm.Algorithm = JetAlgorithm. AntiKt,
126+ strategy:: RecoStrategy.Strategy ,
127+ nsamples:: Integer = 1 ,
128+ backend:: Backends.Backend = Backends. FastJet)
128129
129130 # FastJet reader cannot handle gzipped files
130131 if endswith (input_file, " .gz" )
@@ -136,17 +137,24 @@ function fastjet_jet_process_avg_time(input_file::AbstractString;
136137 algorithm = algorithm)
137138
138139 # @warn "FastJet timing not implemented yet"
139- fj_bin = joinpath (@__DIR__ , " .." , " fastjet" , " build" , " fastjet-finder" )
140- fj_args = String[]
141- push! (fj_args, " -p" , string (p))
142- push! (fj_args, " -s" , string (strategy))
143- push! (fj_args, " -R" , string (distance))
144- push! (fj_args, " --ptmin" , string (ptmin))
145-
146- push! (fj_args, " -n" , string (nsamples))
147- @info " Fastjet command: $fj_bin $fj_args $input_file "
148- fj_output = read (` $fj_bin $fj_args $input_file ` , String)
149- tryparse (Float64, match (r" Lowest time per event ([\d\. ]+) us" , fj_output)[1 ])
140+ if backend == Backends. FastJet
141+ bench_dir = " fastjet"
142+ bench_name = " fastjet-finder"
143+ elseif backend == Backends. CJetReconstruction
144+ bench_dir = " cjetreconstruction"
145+ bench_name = " cjetreconstruction-finder"
146+ end
147+ bench_bin = joinpath (@__DIR__ , " .." , bench_dir, " build" , bench_name)
148+ bench_args = String[]
149+ push! (bench_args, " -p" , string (p))
150+ push! (bench_args, " -s" , string (strategy))
151+ push! (bench_args, " -R" , string (distance))
152+ push! (bench_args, " --ptmin" , string (ptmin))
153+
154+ push! (bench_args, " -n" , string (nsamples))
155+ @info " Benchmark command: $bench_bin $bench_args $input_file "
156+ bench_output = read (` $bench_bin $bench_args $input_file ` , String)
157+ tryparse (Float64, match (r" Lowest time per event ([\d\. ]+) us" , bench_output)[1 ])
150158end
151159
152160function parse_command_line (args)
@@ -269,13 +277,14 @@ function main()
269277 p = args[:power ],
270278 strategy = args[:strategy ],
271279 nsamples = samples, repeats = args[:repeats ])
272- elseif args[:backend ] == Backends. FastJet
273- time_per_event = fastjet_jet_process_avg_time (event_file, ptmin = args[:ptmin ],
274- distance = args[:distance ],
275- algorithm = args[:algorithm ],
276- p = args[:power ],
277- strategy = args[:strategy ],
278- nsamples = samples)
280+ elseif args[:backend ] ∈ (Backends. FastJet, Backends. CJetReconstruction)
281+ time_per_event = external_benchmark_avg_time (event_file, ptmin = args[:ptmin ],
282+ distance = args[:distance ],
283+ algorithm = args[:algorithm ],
284+ p = args[:power ],
285+ strategy = args[:strategy ],
286+ nsamples = samples,
287+ backend = args[:backend ])
279288 end
280289
281290 push! (event_timing, time_per_event)
0 commit comments