MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / parseArgs

Function parseArgs

tools/benchmark/node_write_bench.cpp:49–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49static Config parseArgs(int argc, char** argv) {
50 Config config;
51 config.threadCounts.clear();
52 for (int i = 1; i < argc; i++) {
53 const std::string arg = argv[i];
54 if (arg == "--help" || arg == "-h") {
55 usage(argv[0]);
56 std::exit(0);
57 }
58 if (arg == "--seconds" || arg == "-s") {
59 if (++i == argc) {
60 throw std::invalid_argument("--seconds requires a value");
61 }
62 config.seconds = std::stod(argv[i]);
63 if (config.seconds <= 0.0) {
64 throw std::invalid_argument("--seconds must be greater than 0");
65 }
66 continue;
67 }
68 if (arg == "--preserve-db") {
69 config.preserveDB = true;
70 continue;
71 }
72 const auto numThreads = std::stoull(arg);
73 if (numThreads == 0) {
74 throw std::invalid_argument("thread_count must be greater than 0");
75 }
76 config.threadCounts.push_back(numThreads);
77 }
78 if (config.threadCounts.empty()) {
79 config.threadCounts = {1, 2, 4, 8};
80 }
81 return config;
82}
83
84struct CaseResult {
85 uint64_t totalWrites;

Callers 1

mainFunction · 0.85

Calls 4

usageFunction · 0.85
clearMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected