Skip to content

Commit fdd6df0

Browse files
DarksonnGerrit Code Review
authored andcommitted
Merge changes I66d15781,I4568eb55 into main
* changes: binderThroughputTest: skip benchmark loop for servers binderThroughputTest: gather servers right away
2 parents 57ca711 + 625212e commit fdd6df0

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

libs/binder/tests/binderThroughputTest.cpp

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,29 +220,34 @@ void worker_fx(int num,
220220
workers.push_back(serviceMgr->waitForService(generateServiceName(i)));
221221
}
222222

223-
// Run the benchmark if client
224-
ProcResults results(iterations);
223+
p.signal();
224+
p.wait();
225225

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

240-
uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count());
241-
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;
242235

243-
if (ret != NO_ERROR) {
244-
cout << "thread " << num << " failed " << ret << "i : " << i << endl;
245-
exit(EXIT_FAILURE);
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);
246+
247+
if (ret != NO_ERROR) {
248+
cout << "thread " << num << " failed " << ret << "i : " << i << endl;
249+
exit(EXIT_FAILURE);
250+
}
246251
}
247252
}
248253

@@ -300,8 +305,15 @@ void run_main(int iterations,
300305
pipes.push_back(make_worker(i, iterations, workers, payload_size, cs_pair));
301306
}
302307
wait_all(pipes);
308+
// All workers have now been spawned and added themselves to service
309+
// manager. Signal each worker to obtain a handle to the server workers from
310+
// servicemanager.
311+
signal_all(pipes);
312+
// Wait for each worker to finish obtaining a handle to all server workers
313+
// from servicemanager.
314+
wait_all(pipes);
303315

304-
// Run the workers and wait for completion.
316+
// Run the benchmark and wait for completion.
305317
chrono::time_point<chrono::high_resolution_clock> start, end;
306318
cout << "waiting for workers to complete" << endl;
307319
start = chrono::high_resolution_clock::now();

0 commit comments

Comments
 (0)