diff options
| author | 2023-09-23 22:41:22 +0000 | |
|---|---|---|
| committer | 2024-01-05 12:42:30 +0000 | |
| commit | 9a85d30228b2752f08887d5f40f7c18c25af959d (patch) | |
| tree | 8bb040a737b87523590847ec0c7f52f6318ebc4a | |
| parent | b21d7fdac110502e77e6e9e6f7c7681fc991d784 (diff) | |
binderThroughputTest: only parse user latency once
The latency seems already capped by atoi() so there is no need of doing
a reparse via strtoull(). Besides any values above INT_MAX microseconds
don't really make sense for this test. The conversion into nanoseconds
doesn't overflow this way either: INT_MAX * 1000ull < UINT64_MAX.
Change-Id: I603bbeee2e94c9975e502c1af1c1c2bbcc82f79a
Signed-off-by: Carlos Llamas <cmllamas@google.com>
| -rw-r--r-- | libs/binder/tests/binderThroughputTest.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp index 0a5518e2cd..e4c6fa406e 100644 --- a/libs/binder/tests/binderThroughputTest.cpp +++ b/libs/binder/tests/binderThroughputTest.cpp @@ -337,6 +337,7 @@ int main(int argc, char *argv[]) int payload_size = 0; bool cs_pair = false; bool training_round = false; + int max_time_us; // Parse arguments. for (int i = 1; i < argc; i++) { @@ -381,14 +382,14 @@ int main(int argc, char *argv[]) if (string(argv[i]) == "-m") { // Caller specified the max latency in microseconds. // No need to run training round in this case. - if (atoi(argv[i+1]) > 0) { - max_time_bucket = strtoull(argv[i+1], (char **)nullptr, 10) * 1000; - time_per_bucket = max_time_bucket / num_buckets; - i++; - } else { + max_time_us = atoi(argv[i+1]); + if (max_time_us <= 0) { cout << "Max latency -m must be positive." << endl; exit(EXIT_FAILURE); } + max_time_bucket = max_time_us * 1000ull; + time_per_bucket = max_time_bucket / num_buckets; + i++; continue; } } |