| 100 | return (uint64_t)v; |
| 101 | } |
| 102 | |
| 103 | static double bytes_to_gib(uint64_t bytes) { |
| 104 | return (double)bytes / (1024.0 * 1024.0 * 1024.0); |
| 105 | } |
| 106 | |
| 107 | static void usage(FILE *fp, const char *topic) { |
| 108 | ds4_help_print(fp, DS4_HELP_BENCH, topic); |
| 109 | } |
| 110 | |
| 111 | static int parse_int(const char *s, const char *opt) { |
| 112 | char *end = NULL; |
| 113 | long v = strtol(s, &end, 10); |
| 114 | if (s[0] == '\0' || *end != '\0' || v <= 0 || v > INT_MAX) { |
| 115 | fprintf(stderr, "ds4-bench: invalid value for %s: %s\n", opt, s); |
| 116 | exit(2); |
| 117 | } |
| 118 | return (int)v; |
| 119 | } |
| 120 | |