MCPcopy Create free account
hub / github.com/RenderKit/embree / TutorialBenchmark

Class TutorialBenchmark

tutorials/common/tutorial/benchmark.h:76–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74using BuildBenchFunc = void(*)(BenchState& state, BenchParams& params, BuildBenchParams& buildParams, int argc, char** argv);
75
76struct TutorialBenchmark
77{
78 static bool benchmark(int argc, char** argv) {
79 for (int i = 0; i < argc; ++i)
80 if (std::string(argv[i]) == "--benchmark")
81 return true;
82 return false;
83 }
84
85 TutorialBenchmark(BenchFunc func) :
86 commandLineParser(CommandLineParser(CommandLineParser::SILENT)),
87 func(func)
88 {
89 commandLineParser.registerOption("help", [this] (Ref<ParseStream> cin, const FileName& path) {
90 commandLineParser.printCommandLineHelp();
91 exit(1);
92 }, "--help: prints help for all supported command line options");
93 commandLineParser.registerOption("i", [&] (Ref<ParseStream> cin, const FileName& path) {
94 inputFile = cin->getString();
95 }, "-i <filepath>: .xml ");
96 commandLineParser.registerOption("c", [&] (Ref<ParseStream> cin, const FileName& path) {
97 inputFile = cin->getString();
98 }, "-c <filepath>: .ecs ");
99 commandLineParser.registerOption("benchmark", [&] (Ref<ParseStream> cin, const FileName& path) {
100 params.skipIterations = cin->getInt();
101 params.minTimeOrIterations = cin->getInt();
102 processedCommandLineOptions.push_back("--benchmark");
103 }, "--benchmark <N> <M>: run benchmark for M seconds (M iterations in legacy mode) with N iterations warm-up");
104 commandLineParser.registerOption("legacy", [&] (Ref<ParseStream> cin, const FileName& path) {
105 params.legacy = true;
106 processedCommandLineOptions.push_back("--legacy");
107 }, "--legacy: run old benchmark version (without google benchmark)");
108 commandLineParser.registerOption("benchmark_repetitions", [&] (Ref<ParseStream> cin, const FileName& path) {
109 params.repetitions = cin->getInt();
110 processedCommandLineOptions.push_back("--benchmark_repetitions");
111 }, "--benchmark_repetitions <R>: run R repetitions when using google benchmark");
112 commandLineParser.registerOption("benchmark_name", [&] (Ref<ParseStream> cin, const FileName& path) {
113 params.name = cin->getString();
114 processedCommandLineOptions.push_back("--benchmark_name");
115 }, "--benchmark_name <string>: override name of the benchmark");
116 }
117
118 TutorialBenchmark() : TutorialBenchmark(nullptr)
119 {
120 }
121
122 int main(int argc, char** argv, std::string name = "default");
123
124protected:
125 CommandLineParser commandLineParser;
126
127 // remove the processed commdand line options
128 void updateCommandLine(int& argc, char** argv);
129 virtual void postParseCommandLine();
130
131 std::string inputFile = "";
132 std::vector<std::string> processedCommandLineOptions;
133 BenchParams params;

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected