55
66static void BM_Street_Construction (benchmark::State& state) {
77 for (auto _ : state) {
8- dsf::mobility::Street street (0 ,
9- {0 , 1 },
10- 100.0 ,
11- 13.8888888889 ,
12- 2 ,
13- " test" ,
14- {},
15- std::nullopt ,
16- 1.0 );
8+ dsf::mobility::Street street (
9+ 0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, std::nullopt , 1.0 );
1710 benchmark::DoNotOptimize (street);
1811 }
1912}
@@ -36,15 +29,7 @@ static void BM_Street_AddAgent(benchmark::State& state) {
3629}
3730
3831static void BM_Street_Enqueue (benchmark::State& state) {
39- dsf::mobility::Street street (0 ,
40- {0 , 1 },
41- 100.0 ,
42- 13.8888888889 ,
43- 2 ,
44- " test" ,
45- {},
46- 100 ,
47- 1.0 );
32+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
4833 std::time_t spawnTime = 0 ;
4934 for (int i = 0 ; i < 50 ; ++i) {
5035 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -60,15 +45,7 @@ static void BM_Street_Enqueue(benchmark::State& state) {
6045}
6146
6247static void BM_Street_Dequeue (benchmark::State& state) {
63- dsf::mobility::Street street (0 ,
64- {0 , 1 },
65- 100.0 ,
66- 13.8888888889 ,
67- 2 ,
68- " test" ,
69- {},
70- 100 ,
71- 1.0 );
48+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
7249 std::time_t spawnTime = 0 ;
7350 for (int i = 0 ; i < 50 ; ++i) {
7451 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -85,20 +62,13 @@ static void BM_Street_Dequeue(benchmark::State& state) {
8562}
8663
8764static void BM_Street_nAgents (benchmark::State& state) {
88- dsf::mobility::Street street (0 ,
89- {0 , 1 },
90- 100.0 ,
91- 13.8888888889 ,
92- 2 ,
93- " test" ,
94- {},
95- 100 ,
96- 1.0 );
65+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
9766 std::time_t spawnTime = 0 ;
9867 for (int i = 0 ; i < 50 ; ++i) {
9968 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
10069 street.addAgent (std::move (agent));
101- if (i % 2 == 0 ) street.enqueue (0 );
70+ if (i % 2 == 0 )
71+ street.enqueue (0 );
10272 }
10373 for (auto _ : state) {
10474 int n = street.nAgents ();
@@ -107,20 +77,13 @@ static void BM_Street_nAgents(benchmark::State& state) {
10777}
10878
10979static void BM_Street_Density (benchmark::State& state) {
110- dsf::mobility::Street street (0 ,
111- {0 , 1 },
112- 100.0 ,
113- 13.8888888889 ,
114- 2 ,
115- " test" ,
116- {},
117- 100 ,
118- 1.0 );
80+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
11981 std::time_t spawnTime = 0 ;
12082 for (int i = 0 ; i < 50 ; ++i) {
12183 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
12284 street.addAgent (std::move (agent));
123- if (i % 2 == 0 ) street.enqueue (0 );
85+ if (i % 2 == 0 )
86+ street.enqueue (0 );
12487 }
12588 for (auto _ : state) {
12689 double d = street.density (false );
@@ -129,15 +92,7 @@ static void BM_Street_Density(benchmark::State& state) {
12992}
13093
13194static void BM_Street_nMovingAgents (benchmark::State& state) {
132- dsf::mobility::Street street (0 ,
133- {0 , 1 },
134- 100.0 ,
135- 13.8888888889 ,
136- 2 ,
137- " test" ,
138- {},
139- 100 ,
140- 1.0 );
95+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
14196 std::time_t spawnTime = 0 ;
14297 for (int i = 0 ; i < 50 ; ++i) {
14398 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -150,15 +105,7 @@ static void BM_Street_nMovingAgents(benchmark::State& state) {
150105}
151106
152107static void BM_Street_nExitingAgents (benchmark::State& state) {
153- dsf::mobility::Street street (0 ,
154- {0 , 1 },
155- 100.0 ,
156- 13.8888888889 ,
157- 2 ,
158- " test" ,
159- {},
160- 100 ,
161- 1.0 );
108+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
162109 std::time_t spawnTime = 0 ;
163110 for (int i = 0 ; i < 50 ; ++i) {
164111 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -172,86 +119,47 @@ static void BM_Street_nExitingAgents(benchmark::State& state) {
172119}
173120
174121static void BM_Street_SetLaneMapping (benchmark::State& state) {
175- dsf::mobility::Street street (0 ,
176- {0 , 1 },
177- 100.0 ,
178- 13.8888888889 ,
179- 3 ,
180- " test" ,
181- {},
182- std::nullopt ,
183- 1.0 );
122+ dsf::mobility::Street street (
123+ 0 , {0 , 1 }, 100.0 , 13.8888888889 , 3 , " test" , {}, std::nullopt , 1.0 );
184124 std::vector<dsf::Direction> laneMapping = {
185- dsf::Direction::RIGHTANDSTRAIGHT,
186- dsf::Direction::STRAIGHT,
187- dsf::Direction::LEFT};
125+ dsf::Direction::RIGHTANDSTRAIGHT, dsf::Direction::STRAIGHT, dsf::Direction::LEFT};
188126 for (auto _ : state) {
189127 street.setLaneMapping (laneMapping);
190128 }
191129}
192130
193131static void BM_StochasticStreet_SetFlowRate (benchmark::State& state) {
194- dsf::mobility::Street baseStreet (0 ,
195- {0 , 1 },
196- 100.0 ,
197- 13.8888888889 ,
198- 2 ,
199- " test" ,
200- {},
201- std::nullopt ,
202- 1.0 );
132+ dsf::mobility::Street baseStreet (
133+ 0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, std::nullopt , 1.0 );
203134 dsf::mobility::StochasticStreet street (std::move (baseStreet), 0.5 );
204135 for (auto _ : state) {
205136 street.setFlowRate (0.8 );
206137 }
207138}
208139
209140static void BM_StochasticStreet_FlowRate (benchmark::State& state) {
210- dsf::mobility::Street baseStreet (0 ,
211- {0 , 1 },
212- 100.0 ,
213- 13.8888888889 ,
214- 2 ,
215- " test" ,
216- {},
217- std::nullopt ,
218- 1.0 );
141+ dsf::mobility::Street baseStreet (
142+ 0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, std::nullopt , 1.0 );
219143 dsf::mobility::StochasticStreet street (std::move (baseStreet), 0.5 );
220144 for (auto _ : state) {
221145 double fr = street.flowRate ();
222146 benchmark::DoNotOptimize (fr);
223147 }
224148}
225149
226- static void BM_SpireStreet_AddAgent (benchmark::State& state) {
227- dsf::mobility::Street baseStreet (0 ,
228- {0 , 1 },
229- 100.0 ,
230- 13.8888888889 ,
231- 2 ,
232- " test" ,
233- {},
234- 100 ,
235- 1.0 );
236- dsf::mobility::SpireStreet street (std::move (baseStreet));
150+ static void BM_CoilStreet_AddAgent (benchmark::State& state) {
151+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
152+ street.enableCounter ();
237153 std::time_t spawnTime = 0 ;
238154 for (auto _ : state) {
239155 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
240156 street.addAgent (std::move (agent));
241157 }
242158}
243159
244- static void BM_SpireStreet_MeanFlow (benchmark::State& state) {
245- dsf::mobility::Street baseStreet (0 ,
246- {0 , 1 },
247- 100.0 ,
248- 13.8888888889 ,
249- 2 ,
250- " test" ,
251- {},
252- 100 ,
253- 1.0 );
254- dsf::mobility::SpireStreet street (std::move (baseStreet));
160+ static void BM_CoilStreet_MeanFlow (benchmark::State& state) {
161+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
162+ street.enableCounter ();
255163 std::time_t spawnTime = 0 ;
256164 for (int i = 0 ; i < 50 ; ++i) {
257165 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -262,22 +170,14 @@ static void BM_SpireStreet_MeanFlow(benchmark::State& state) {
262170 }
263171 }
264172 for (auto _ : state) {
265- int flow = street.meanFlow ();
173+ auto flow = street.counts ();
266174 benchmark::DoNotOptimize (flow);
267175 }
268176}
269177
270- static void BM_SpireStreet_Dequeue (benchmark::State& state) {
271- dsf::mobility::Street baseStreet (0 ,
272- {0 , 1 },
273- 100.0 ,
274- 13.8888888889 ,
275- 2 ,
276- " test" ,
277- {},
278- 100 ,
279- 1.0 );
280- dsf::mobility::SpireStreet street (std::move (baseStreet));
178+ static void BM_CoilStreet_Dequeue (benchmark::State& state) {
179+ dsf::mobility::Street street (0 , {0 , 1 }, 100.0 , 13.8888888889 , 2 , " test" , {}, 100 , 1.0 );
180+ street.enableCounter ();
281181 std::time_t spawnTime = 0 ;
282182 for (int i = 0 ; i < 50 ; ++i) {
283183 auto agent = std::make_unique<dsf::mobility::Agent>(spawnTime++, 1 , 0 );
@@ -304,8 +204,8 @@ BENCHMARK(BM_Street_nExitingAgents);
304204BENCHMARK (BM_Street_SetLaneMapping);
305205BENCHMARK (BM_StochasticStreet_SetFlowRate);
306206BENCHMARK (BM_StochasticStreet_FlowRate);
307- BENCHMARK (BM_SpireStreet_AddAgent );
308- BENCHMARK (BM_SpireStreet_MeanFlow );
309- BENCHMARK (BM_SpireStreet_Dequeue );
207+ BENCHMARK (BM_CoilStreet_AddAgent );
208+ BENCHMARK (BM_CoilStreet_MeanFlow );
209+ BENCHMARK (BM_CoilStreet_Dequeue );
310210
311211BENCHMARK_MAIN ();
0 commit comments