Changeset d17cf8c in mainline for uspace/app/hbench/main.c
- Timestamp:
- 2019-01-21T13:39:37Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 94d52d5
- Parents:
- e7f9a09
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hbench/main.c
re7f9a09 rd17cf8c 148 148 } 149 149 150 static bool run_benchmark(bench mark_t *bench)150 static bool run_benchmark(bench_env_t *env, benchmark_t *bench) 151 151 { 152 152 printf("Warm up and determine workload size...\n"); … … 169 169 170 170 if (bench->setup != NULL) { 171 ret = bench->setup( &helper_run);171 ret = bench->setup(env, &helper_run); 172 172 if (!ret) { 173 173 goto leave_error; … … 190 190 bench_run_init(&run, error_msg, MAX_ERROR_STR_LENGTH); 191 191 192 bool ok = bench->entry( &run, workload_size);192 bool ok = bench->entry(env, &run, workload_size); 193 193 if (!ok) { 194 194 goto leave_error; … … 212 212 bench_run_init(&runs[i], error_msg, MAX_ERROR_STR_LENGTH); 213 213 214 bool ok = bench->entry( &runs[i], workload_size);214 bool ok = bench->entry(env, &runs[i], workload_size); 215 215 if (!ok) { 216 216 free(runs); … … 233 233 leave: 234 234 if (bench->teardown != NULL) { 235 bool ok = bench->teardown( &helper_run);235 bool ok = bench->teardown(env, &helper_run); 236 236 if (!ok) { 237 237 printf("Error: %s\n", error_msg); … … 245 245 } 246 246 247 static int run_benchmarks( void)247 static int run_benchmarks(bench_env_t *env) 248 248 { 249 249 unsigned int count_ok = 0; … … 256 256 for (size_t it = 0; it < benchmark_count; it++) { 257 257 printf("%s (%s)\n", benchmarks[it]->name, benchmarks[it]->desc); 258 if (run_benchmark( benchmarks[it])) {258 if (run_benchmark(env, benchmarks[it])) { 259 259 count_ok++; 260 260 continue; … … 314 314 } 315 315 316 static void handle_param_arg( char *arg)316 static void handle_param_arg(bench_env_t *env, char *arg) 317 317 { 318 318 char *value = NULL; 319 319 char *key = str_tok(arg, "=", &value); 320 bench_ param_set(key, value);320 bench_env_param_set(env, key, value); 321 321 } 322 322 323 323 int main(int argc, char *argv[]) 324 324 { 325 errno_t rc = bench_param_init(); 325 bench_env_t bench_env; 326 errno_t rc = bench_env_init(&bench_env); 326 327 if (rc != EOK) { 327 328 fprintf(stderr, "Failed to initialize internal params structure: %s\n", … … 350 351 break; 351 352 case 'p': 352 handle_param_arg( optarg);353 handle_param_arg(&bench_env, optarg); 353 354 break; 354 355 case -1: … … 378 379 379 380 if (str_cmp(benchmark, "*") == 0) { 380 exit_code = run_benchmarks( );381 exit_code = run_benchmarks(&bench_env); 381 382 } else { 382 383 bool benchmark_exists = false; … … 384 385 if (str_cmp(benchmark, benchmarks[i]->name) == 0) { 385 386 benchmark_exists = true; 386 exit_code = run_benchmark( benchmarks[i]) ? 0 : -1;387 exit_code = run_benchmark(&bench_env, benchmarks[i]) ? 0 : -1; 387 388 break; 388 389 } … … 395 396 396 397 csv_report_close(); 397 bench_ param_cleanup();398 bench_env_cleanup(&bench_env); 398 399 399 400 return exit_code;
Note:
See TracChangeset
for help on using the changeset viewer.