diff options
| author | 2024-01-15 11:49:47 +0000 | |
|---|---|---|
| committer | 2024-01-15 11:49:47 +0000 | |
| commit | 98f2e04b02fa4eae943c8cca7a21988f5ff043c0 (patch) | |
| tree | 928cb0e1b68316575b678ed8d8a91b8d74309cce | |
| parent | 6ed47691a17e595b641ddcb6f5b8ed55a0a6451a (diff) | |
| parent | b2a1c4db2c02a2079ed7bf736c249c7e5d62c396 (diff) | |
Merge changes I66d15781,I4568eb55 into main am: fdd6df043c am: db2765912b am: b2a1c4db2c
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2759943
Change-Id: I0ce01683a9cc78f9629f0ec564f55467ae1ca701
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | libs/binder/tests/binderThroughputTest.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp index d7f631828a..10912c7363 100644 --- a/libs/binder/tests/binderThroughputTest.cpp +++ b/libs/binder/tests/binderThroughputTest.cpp @@ -220,29 +220,34 @@ void worker_fx(int num, workers.push_back(serviceMgr->waitForService(generateServiceName(i))); } - // Run the benchmark if client - ProcResults results(iterations); + p.signal(); + p.wait(); + ProcResults results(iterations); chrono::time_point<chrono::high_resolution_clock> start, end; - for (int i = 0; (!cs_pair || num >= server_count) && i < iterations; i++) { - Parcel data, reply; - int target = cs_pair ? num % server_count : rand() % workers.size(); - int sz = payload_size; - - while (sz >= sizeof(uint32_t)) { - data.writeInt32(0); - sz -= sizeof(uint32_t); - } - start = chrono::high_resolution_clock::now(); - status_t ret = workers[target]->transact(BINDER_NOP, data, &reply); - end = chrono::high_resolution_clock::now(); - uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count()); - results.add_time(cur_time); + // Skip the benchmark if server of a cs_pair. + if (!(cs_pair && num < server_count)) { + for (int i = 0; i < iterations; i++) { + Parcel data, reply; + int target = cs_pair ? num % server_count : rand() % workers.size(); + int sz = payload_size; - if (ret != NO_ERROR) { - cout << "thread " << num << " failed " << ret << "i : " << i << endl; - exit(EXIT_FAILURE); + while (sz >= sizeof(uint32_t)) { + data.writeInt32(0); + sz -= sizeof(uint32_t); + } + start = chrono::high_resolution_clock::now(); + status_t ret = workers[target]->transact(BINDER_NOP, data, &reply); + end = chrono::high_resolution_clock::now(); + + uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count()); + results.add_time(cur_time); + + if (ret != NO_ERROR) { + cout << "thread " << num << " failed " << ret << "i : " << i << endl; + exit(EXIT_FAILURE); + } } } @@ -300,8 +305,15 @@ void run_main(int iterations, pipes.push_back(make_worker(i, iterations, workers, payload_size, cs_pair)); } wait_all(pipes); + // All workers have now been spawned and added themselves to service + // manager. Signal each worker to obtain a handle to the server workers from + // servicemanager. + signal_all(pipes); + // Wait for each worker to finish obtaining a handle to all server workers + // from servicemanager. + wait_all(pipes); - // Run the workers and wait for completion. + // Run the benchmark and wait for completion. chrono::time_point<chrono::high_resolution_clock> start, end; cout << "waiting for workers to complete" << endl; start = chrono::high_resolution_clock::now(); |