23 using namespace Acts::UnitLiterals;
25 int main(
int argc,
char* argv[]) {
26 size_t iters_map = 5e2;
27 size_t iters_solenoid = 3;
28 size_t runs_solenoid = 1000;
30 iters_map = std::stoi(argv[1]);
33 iters_solenoid = std::stoi(argv[2]);
36 runs_solenoid = std::stoi(argv[3]);
39 const double L = 5.8_m;
40 const double R = (2.56 + 2.46) * 0.5 * 0.5_m;
41 const size_t nCoils = 1154;
48 double zMin = 2 * (-L / 2.);
49 double zMax = 2 * (L / 2.);
52 std::cout <<
"Building interpolated field map" << std::endl;
58 std::uniform_real_distribution<> zDist(1.5 * (-L / 2.), 1.5 * L / 2.);
59 std::uniform_real_distribution<> rDist(0, R * 1.5);
60 std::uniform_real_distribution<>
phiDist(-M_PI, M_PI);
62 const double z = zDist(rng),
r = rDist(rng),
phi =
phiDist(rng);
63 return {
r * std::cos(
phi),
r * std::sin(
phi), z};
66 std::ofstream
os{
"bfield_bench.csv"};
69 os << name <<
"," << res.run_timings.size() <<
"," << res.iters_per_run
70 <<
"," << res.totalTime().count() <<
"," << res.runTimeMedian().count()
71 <<
"," << 1.96 * res.runTimeError().count() <<
","
72 << res.iterTimeAverage().count() <<
","
73 << 1.96 * res.iterTimeError().count();
78 os <<
"name,runs,iters,total_time,run_time_median,run_time_error,iter_"
79 "time_average,iter_time_error"
84 std::cout <<
"Benchmarking random SolenoidBField lookup: " <<
std::flush;
88 std::cout << solenoid_result << std::endl;
89 csv(
"solenoid", solenoid_result);
99 std::cout <<
"Benchmarking interpolated field lookup: " <<
std::flush;
100 const auto fixedPos = genPos();
102 [&] {
return bFieldMap.getField(fixedPos); }, iters_map);
103 std::cout << map_fixed_nocache_result << std::endl;
104 csv(
"interp_nocache_fixed", map_fixed_nocache_result);
106 std::cout <<
"Benchmarking random interpolated field lookup: " <<
std::flush;
112 [&] {
return bFieldMap.getField(genPos()); }, iters_map);
113 std::cout << map_rand_result << std::endl;
114 csv(
"interp_nocache_random", map_rand_result);
121 std::cout <<
"Benchmarking cached interpolated field lookup: "
125 [&] {
return bFieldMap.getField(fixedPos, cache).value(); }, iters_map);
126 std::cout << map_cached_result_cache << std::endl;
127 csv(
"interp_cache_fixed", map_cached_result_cache);
135 std::cout <<
"Benchmarking cached random interpolated field lookup: "
139 [&] {
return bFieldMap.getField(genPos(), cache2).value(); },
141 std::cout << map_rand_result_cache << std::endl;
142 csv(
"interp_cache_random", map_rand_result_cache);
151 std::cout <<
"Benchmarking advancing interpolated field lookup: "
157 std::vector<Acts::Vector3>
steps;
158 steps.reserve(iters_map);
159 for (
size_t i = 0;
i < iters_map;
i++) {
165 steps.push_back(
pos);
169 std::cout << map_adv_result << std::endl;
170 csv(
"interp_nocache_adv", map_adv_result);
178 std::cout <<
"Benchmarking cached advancing interpolated field lookup: "
182 [&](
const auto&
s) {
return bFieldMap.getField(
s, cache).value(); },
184 std::cout << map_adv_result_cache << std::endl;
185 csv(
"interp_cache_adv", map_adv_result_cache);