Skip to content

Commit f4dbc08

Browse files
authored
DPL: make benchmark ready for new ownership model (#15562)
Rather than relying on a moveable container, move elements one by one. This works the same for both ownership models and since it's just some benchmark internal buffer, it does not advantage the owning model vs the non owning.
1 parent b248548 commit f4dbc08

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

Framework/Core/test/benchmark_DataRelayer.cxx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <Monitoring/Monitoring.h>
2626
#include <fairmq/TransportFactory.h>
2727
#include <cstring>
28+
#include <iterator>
2829
#include <vector>
2930
#include <uv.h>
3031

@@ -140,7 +141,8 @@ static void BM_RelaySingleSlot(benchmark::State& state)
140141
auto result = relayer.consumeAllInputsForTimeslice(ready[0].slot);
141142
assert(result.size() == 1);
142143
assert((result.at(0) | count_parts{}) == 1);
143-
inflightMessages = std::move(result[0]);
144+
inflightMessages.assign(std::make_move_iterator(result[0].begin()),
145+
std::make_move_iterator(result[0].end()));
144146
}
145147
}
146148

@@ -196,7 +198,8 @@ static void BM_RelayMultipleSlots(benchmark::State& state)
196198
auto result = relayer.consumeAllInputsForTimeslice(ready[0].slot);
197199
assert(result.size() == 1);
198200
assert((result.at(0) | count_parts{}) == 1);
199-
inflightMessages = std::move(result[0]);
201+
inflightMessages.assign(std::make_move_iterator(result[0].begin()),
202+
std::make_move_iterator(result[0].end()));
200203
}
201204
}
202205

@@ -271,9 +274,11 @@ static void BM_RelayMultipleRoutes(benchmark::State& state)
271274
assert(result.size() == 2);
272275
assert((result.at(0) | count_parts{}) == 1);
273276
assert((result.at(1) | count_parts{}) == 1);
274-
inflightMessages = std::move(result[0]);
275-
inflightMessages.emplace_back(std::move(result[1][0]));
276-
inflightMessages.emplace_back(std::move(result[1][1]));
277+
inflightMessages.assign(std::make_move_iterator(result[0].begin()),
278+
std::make_move_iterator(result[0].end()));
279+
inflightMessages.insert(inflightMessages.end(),
280+
std::make_move_iterator(result[1].begin()),
281+
std::make_move_iterator(result[1].end()));
277282
}
278283
}
279284

@@ -333,7 +338,9 @@ static void BM_RelaySplitParts(benchmark::State& state)
333338
relayer.getReadyToProcess(ready);
334339
assert(ready.size() == 1);
335340
assert(ready[0].op == CompletionPolicy::CompletionOp::Consume);
336-
inflightMessages = std::move(relayer.consumeAllInputsForTimeslice(ready[0].slot)[0]);
341+
auto result = relayer.consumeAllInputsForTimeslice(ready[0].slot);
342+
inflightMessages.assign(std::make_move_iterator(result[0].begin()),
343+
std::make_move_iterator(result[0].end()));
337344
}
338345
}
339346

@@ -387,7 +394,9 @@ static void BM_RelayMultiplePayloads(benchmark::State& state)
387394
relayer.getReadyToProcess(ready);
388395
assert(ready.size() == 1);
389396
assert(ready[0].op == CompletionPolicy::CompletionOp::Consume);
390-
inflightMessages = std::move(relayer.consumeAllInputsForTimeslice(ready[0].slot)[0]);
397+
auto result = relayer.consumeAllInputsForTimeslice(ready[0].slot);
398+
inflightMessages.assign(std::make_move_iterator(result[0].begin()),
399+
std::make_move_iterator(result[0].end()));
391400
}
392401
}
393402

0 commit comments

Comments
 (0)