MCPcopy Create free account
hub / github.com/catboost/catboost / Main

Method Main

library/cpp/testing/benchmark/bench.cpp:573–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573int NBench::Main(int argc, char** argv) {
574 const TProgOpts opts(argc, argv);
575
576 TVector<ITestRunner*> tests;
577
578 for (auto&& it : Tests()) {
579 if (opts.MatchFilters(it.Name())) {
580 tests.push_back(&it);
581 }
582 }
583 EnumerateTests(tests);
584
585 if (opts.ListTests) {
586 for (const auto* const it : tests) {
587 Cout << it->Name() << Endl;
588 }
589
590 return 0;
591 }
592
593 if (!tests) {
594 return 0;
595 }
596
597 double timeBudget = opts.TimeBudget;
598
599 if (timeBudget < 0) {
600 timeBudget = 5.0 * tests.size();
601 }
602
603
604 THolder<IOutputStream> outputHolder;
605 IOutputStream* outputStream = &Cout;
606
607 if (opts.ReportPath != "") {
608 TString filePath(opts.ReportPath);
609 outputHolder.Reset(outputStream = new TFileOutput(filePath));
610 }
611
612 const TOptions testOpts = {timeBudget / tests.size()};
613 const auto reporter = MakeOrderedReporter(opts.OutFormat, *outputStream);
614
615 std::function<void(ITestRunner**)> func = [&](ITestRunner** it) {
616 auto&& res = (*it)->Run(testOpts);
617
618 reporter->Report(std::move(res));
619 };
620
621 if (opts.Threads > 1) {
622 NYmp::SetThreadCount(opts.Threads);
623 NYmp::ParallelForStaticChunk(tests.data(), tests.data() + tests.size(), 1, func);
624 } else {
625 for (auto it : tests) {
626 func(&it);
627 }
628 }
629
630 reporter->Finish();

Callers

nothing calls this directly

Calls 15

EnumerateTestsFunction · 0.85
MakeOrderedReporterFunction · 0.85
SetThreadCountFunction · 0.85
ParallelForStaticChunkFunction · 0.85
funcFunction · 0.85
MatchFiltersMethod · 0.80
moveFunction · 0.50
NameMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
ResetMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected