Changeset 980611d5 in mainline


Ignore:
Timestamp:
2019-01-01T17:43:54Z (5 years ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e85d2b
Parents:
d5caf79
Message:

perf: use uint64_t for workload size

We also check that we do not overflow with uint64_t (that can rarely
happen if the benchmark is properly designed but we want to be on the
safe side).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/perf/perf.c

    rd5caf79 r980611d5  
    107107        }
    108108
    109         size_t workload_size = 1;
    110 
    111         while (true) {
     109        /*
     110         * Find workload size that is big enough to last few seconds.
     111         * We also check that uint64_t is big enough.
     112         */
     113        uint64_t workload_size = 0;
     114        for (size_t bits = 0; bits <= 64; bits++) {
     115                if (bits == 64) {
     116                        str_cpy(error_msg, MAX_ERROR_STR_LENGTH, "Workload too small even for 1 << 63");
     117                        goto leave_error;
     118                }
     119                workload_size = ((uint64_t) 1) << bits;
     120
    112121                stopwatch_t stopwatch = STOPWATCH_INITIALIZE_STATIC;
    113122
     
    123132                        break;
    124133                }
    125                 workload_size *= 2;
    126         }
    127 
    128         printf("Workload size set to %zu, measuring %d samples.\n", workload_size, NUM_SAMPLES);
     134        }
     135
     136        printf("Workload size set to %" PRIu64 ", measuring %d samples.\n", workload_size, NUM_SAMPLES);
    129137
    130138        stopwatch_t *stopwatch = calloc(NUM_SAMPLES, sizeof(stopwatch_t));
Note: See TracChangeset for help on using the changeset viewer.