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>
diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp
index 0a5518e..e4c6fa4 100644
--- a/libs/binder/tests/binderThroughputTest.cpp
+++ b/libs/binder/tests/binderThroughputTest.cpp
@@ -337,6 +337,7 @@
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 @@
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;
}
}