@@ -415,13 +415,43 @@ void parseArguments(int argc, char *argv[])
415
415
{
416
416
use_float = true ;
417
417
}
418
- else if (!string (" --triad-only " ).compare (argv[i]))
418
+ else if (!string (" --print-names " ).compare (argv[i]))
419
419
{
420
- selection = Benchmark::Triad;
420
+ cout << " Available benchmarks: " ;
421
+ print_labels (cout);
422
+ cout << endl;
423
+ exit (0 );
421
424
}
422
- else if (!string (" --nstream- only" ).compare (argv[i]))
425
+ else if (!string (" --only" ). compare (argv[i]) || ! string ( " -o " ).compare (argv[i]))
423
426
{
424
- selection = Benchmark::Nstream;
427
+ if (++i >= argc)
428
+ {
429
+ cerr << " Expected benchmark name after --only" << endl;
430
+ exit (1 );
431
+ }
432
+ auto key = string (argv[i]);
433
+ if (key == " Classic" )
434
+ {
435
+ selection = Benchmark::Classic;
436
+ }
437
+ else if (key == " All" )
438
+ {
439
+ selection = Benchmark::All;
440
+ }
441
+ else
442
+ {
443
+ auto p = find_if (labels.begin (), labels.end (), [&](char const * label) {
444
+ return string (label) == key;
445
+ });
446
+ if (p == labels.end ()) {
447
+ cerr << " Unknown benchmark name \" " << argv[i] << " \" after --only" << endl;
448
+ cerr << " Available benchmarks: All,Classic," ;
449
+ print_labels (cerr);
450
+ cerr << endl;
451
+ exit (1 );
452
+ }
453
+ selection = (Benchmark)(distance (labels.begin (), p));
454
+ }
425
455
}
426
456
else if (!string (" --csv" ).compare (argv[i]))
427
457
{
@@ -443,8 +473,8 @@ void parseArguments(int argc, char *argv[])
443
473
cout << " -s --arraysize SIZE Use SIZE elements in the array" << endl;
444
474
cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << endl;
445
475
cout << " --float Use floats (rather than doubles)" << endl;
446
- cout << " --triad- only Only run triad " << endl;
447
- cout << " --nstream-only Only run nstream " << endl;
476
+ cout << " -o -- only NAME Only run one benchmark (see --print-names) " << endl;
477
+ cout << " --print-names Prints all available benchmark names " << endl;
448
478
cout << " --csv Output as csv table" << endl;
449
479
cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << endl;
450
480
cout << endl;
0 commit comments