Changeset 871cff9a in mainline
- Timestamp:
- 2019-01-21T18:01:59Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fea752
- Parents:
- 2d81880
- Location:
- uspace/app/hbench
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hbench/env.c
r2d81880 r871cff9a 96 96 } 97 97 98 env->run_count = DEFAULT_RUN_COUNT; 99 env->minimal_run_duration_nanos = MSEC2NSEC(DEFAULT_MIN_RUN_DURATION_SEC); 100 98 101 return EOK; 99 102 } -
uspace/app/hbench/hbench.h
r2d81880 r871cff9a 42 42 #include <perf.h> 43 43 44 #define DEFAULT_RUN_COUNT 10 45 #define DEFAULT_MIN_RUN_DURATION_SEC 10 46 44 47 /** Single run information. 45 48 * … … 60 63 /** Benchmark environment configuration. 61 64 * 62 * Use proper access functions when modifying data inside this structure. 65 * Benchmarking code (runners) should use access functions to read 66 * data from this structure (now only bench_env_param_get). 67 * 68 * Harness can access it directly. 63 69 */ 64 70 typedef struct { 65 71 hash_table_t parameters; 72 size_t run_count; 73 nsec_t minimal_run_duration_nanos; 66 74 } bench_env_t; 67 75 -
uspace/app/hbench/main.c
r2d81880 r871cff9a 49 49 #include "hbench.h" 50 50 51 #define MIN_DURATION_SECS 1052 #define NUM_SAMPLES 1053 51 #define MAX_ERROR_STR_LENGTH 1024 54 52 … … 131 129 ((double) run_count - 1); 132 130 // FIXME: implement sqrt properly 133 *out_duration_sigma = estimate_square_root(sigma2, precision); 131 if (run_count > 1) { 132 *out_duration_sigma = estimate_square_root(sigma2, precision); 133 } else { 134 *out_duration_sigma = NAN; 135 } 134 136 *out_thruput_avg = 1.0 / (inv_thruput_sum / run_count); 135 137 } … … 197 199 198 200 nsec_t duration = stopwatch_get_nanos(&run.stopwatch); 199 if (duration > SEC2NSEC(MIN_DURATION_SECS)) { 200 break; 201 } 202 } 203 204 printf("Workload size set to %" PRIu64 ", measuring %d samples.\n", workload_size, NUM_SAMPLES); 205 206 bench_run_t *runs = calloc(NUM_SAMPLES, sizeof(bench_run_t)); 201 if (duration > env->minimal_run_duration_nanos) { 202 break; 203 } 204 } 205 206 printf("Workload size set to %" PRIu64 ", measuring %zu samples.\n", 207 workload_size, env->run_count); 208 209 bench_run_t *runs = calloc(env->run_count, sizeof(bench_run_t)); 207 210 if (runs == NULL) { 208 211 snprintf(error_msg, MAX_ERROR_STR_LENGTH, "failed allocating memory"); 209 212 goto leave_error; 210 213 } 211 for ( int i = 0; i < NUM_SAMPLES; i++) {214 for (size_t i = 0; i < env->run_count; i++) { 212 215 bench_run_init(&runs[i], error_msg, MAX_ERROR_STR_LENGTH); 213 216 … … 220 223 } 221 224 222 summary_stats(runs, NUM_SAMPLES, bench, workload_size);225 summary_stats(runs, env->run_count, bench, workload_size); 223 226 printf("\nBenchmark completed\n"); 224 227 … … 306 309 printf("-h, --help " 307 310 "Print this help and exit\n"); 311 printf("-d, --duration MILLIS " 312 "Set minimal run duration (milliseconds)\n"); 313 printf("-n, --count N " 314 "Set number of measured runs\n"); 308 315 printf("-o, --output filename.csv " 309 316 "Store machine-readable data in filename.csv\n"); … … 331 338 } 332 339 333 const char *short_options = "ho:p: ";340 const char *short_options = "ho:p:n:d:"; 334 341 struct option long_options[] = { 342 { "duration", required_argument, NULL, 'd' }, 335 343 { "help", optional_argument, NULL, 'h' }, 344 { "count", required_argument, NULL, 'n' }, 345 { "output", required_argument, NULL, 'o' }, 336 346 { "param", required_argument, NULL, 'p' }, 337 { "output", required_argument, NULL, 'o' },338 347 { 0, 0, NULL, 0 } 339 348 }; … … 344 353 while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) > 0) { 345 354 switch (opt) { 355 case 'd': 356 errno = EOK; 357 bench_env.minimal_run_duration_nanos = MSEC2NSEC(atoll(optarg)); 358 if ((errno != EOK) || (bench_env.minimal_run_duration_nanos <= 0)) { 359 fprintf(stderr, "Invalid -d argument.\n"); 360 return -3; 361 } 362 break; 346 363 case 'h': 347 364 print_usage(*argv); 348 365 return 0; 366 case 'n': 367 errno = EOK; 368 bench_env.run_count = (nsec_t) atoll(optarg); 369 if ((errno != EOK) || (bench_env.run_count <= 0)) { 370 fprintf(stderr, "Invalid -n argument.\n"); 371 return -3; 372 } 373 break; 349 374 case 'o': 350 375 csv_output_filename = optarg;
Note:
See TracChangeset
for help on using the changeset viewer.