Skip to content

Commit 625212e

Browse files
Carlos LlamasDarksonn
authored andcommitted
binderThroughputTest: skip benchmark loop for servers
Skip the entire benchmarking loop if this is a server worker instead of asking the same fixed question on every single iteration. Change-Id: I66d1578132099ea1cb4a3b5a10a830bb11b579a2 Test: Ran a benchmark on cuttlefish, and it did not get stuck Signed-off-by: Carlos Llamas <cmllamas@google.com> Co-developed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
1 parent 60a9051 commit 625212e

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

libs/binder/tests/binderThroughputTest.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,31 @@ void worker_fx(int num,
223223
p.signal();
224224
p.wait();
225225

226-
// Run the benchmark if client
227226
ProcResults results(iterations);
228-
229227
chrono::time_point<chrono::high_resolution_clock> start, end;
230-
for (int i = 0; (!cs_pair || num >= server_count) && i < iterations; i++) {
231-
Parcel data, reply;
232-
int target = cs_pair ? num % server_count : rand() % workers.size();
233-
int sz = payload_size;
234-
235-
while (sz >= sizeof(uint32_t)) {
236-
data.writeInt32(0);
237-
sz -= sizeof(uint32_t);
238-
}
239-
start = chrono::high_resolution_clock::now();
240-
status_t ret = workers[target]->transact(BINDER_NOP, data, &reply);
241-
end = chrono::high_resolution_clock::now();
242228

243-
uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count());
244-
results.add_time(cur_time);
229+
// Skip the benchmark if server of a cs_pair.
230+
if (!(cs_pair && num < server_count)) {
231+
for (int i = 0; i < iterations; i++) {
232+
Parcel data, reply;
233+
int target = cs_pair ? num % server_count : rand() % workers.size();
234+
int sz = payload_size;
235+
236+
while (sz >= sizeof(uint32_t)) {
237+
data.writeInt32(0);
238+
sz -= sizeof(uint32_t);
239+
}
240+
start = chrono::high_resolution_clock::now();
241+
status_t ret = workers[target]->transact(BINDER_NOP, data, &reply);
242+
end = chrono::high_resolution_clock::now();
243+
244+
uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count());
245+
results.add_time(cur_time);
245246

246-
if (ret != NO_ERROR) {
247-
cout << "thread " << num << " failed " << ret << "i : " << i << endl;
248-
exit(EXIT_FAILURE);
247+
if (ret != NO_ERROR) {
248+
cout << "thread " << num << " failed " << ret << "i : " << i << endl;
249+
exit(EXIT_FAILURE);
250+
}
249251
}
250252
}
251253

0 commit comments

Comments
 (0)