Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a85d302 authored by Carlos Llamas's avatar Carlos Llamas Committed by Alice Ryhl
Browse files

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: default avatarCarlos Llamas <cmllamas@google.com>
parent b21d7fda
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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;
        }
    }