Repository: bitcoin/bitcoin
File: src/bench/bench_bitcoin.cpp (C++)

Code before:
}

// parses a comma separated list like "10,20,30,50"
static std::vector<double> parseAsymptote(const std::string& str) {
    std::stringstream ss(str);
    std::vector<double> numbers;
    double d;
    char c;
    while (ss >> d) {
        numbers.push_back(d);
        ss >> c;
    }
    return numbers;
}

static uint8_t parsePriorityLevel(const std::string& str) {
    uint8_t levels{0};
    for (const auto& level: SplitString(str, ',')) {
        levels |= benchmark::StringToPriority(level);
    }
    return levels;
}

int main(int argc, char** argv)
{
    ArgsManager argsman;
    SetupBenchArgs(argsman);
    SHA256AutoDetect();
    std::string error;
    if (!argsman.ParseParameters(argc, argv, error)) {
        tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
        return EXIT_FAILURE;
    }

    if (HelpRequested(argsman)) {
        std::cout << "Usage:  bench_bitcoin [options]\n"
                     "\n"
                  << argsman.GetHelpMessage()
                  << "Description:\n"
                     "\n"
                     "  bench_bitcoin executes microbenchmarks. The quality of the benchmark results\n"
                     "  highly depend on the stability of the machine. It can sometimes be difficult\n"
                     "  to get stable, repeatable results, so here are a few tips:\n"
                     "\n"
                     "  * Use pyperf [1] to disable frequency scaling, turbo boost etc. For best\n"
                     "    results, use CPU pinning and CPU isolation (see [2]).\n"
                     "\n"
                     "  * Each call of run() should do exactly the same work. E.g. inserting into\n"
                     "    a std::vector doesn't do that as it will reallocate on certain calls. Make\n"
                     "    sure each run has exactly the same preconditions.\n"
                     "\n"

Review comment (suggestion):
[Braces on new lines for classes, functions, methods.](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c)

Can see you are following style of function above, but function below follows the dev-notes.

Don't feel as strongly about capitalization.

```suggestion
static std::vector<std::string> ParseTestSetupArgs(const ArgsManager& argsman)
{
```

If you want to make `parsePriorityLevel` conform to the dev-notes as well, I support it.

Code after:
    argsman.AddArg("-priority-level=<l1,l2,l3>", strprintf("Run benchmarks of one or multiple priority level(s) (%s), default: '%s'",
                                                           benchmark::ListPriorities(), DEFAULT_PRIORITY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
}

// parses a comma separated list like "10,20,30,50"
static std::vector<double> parseAsymptote(const std::string& str) {
    std::stringstream ss(str);
    std::vector<double> numbers;
    double d;
    char c;
    while (ss >> d) {
        numbers.push_back(d);
        ss >> c;
    }
    return numbers;
}

static uint8_t parsePriorityLevel(const std::string& str) {
    uint8_t levels{0};
    for (const auto& level: SplitString(str, ',')) {
        levels |= benchmark::StringToPriority(level);
    }
    return levels;
}

static std::vector<std::string> parseTestSetupArgs(const ArgsManager& argsman)
{
    // Parses unit test framework arguments supported by the benchmark framework.
    std::vector<std::string> args;
    static std::vector<std::string> AVAILABLE_ARGS = {"-testdatadir"};
    for (const std::string& arg_name : AVAILABLE_ARGS) {
        auto op_arg = argsman.GetArg(arg_name);
        if (op_arg) args.emplace_back(strprintf("%s=%s", arg_name, *op_arg));
    }
    return args;
}

int main(int argc, char** argv)
{
    ArgsManager argsman;
    SetupBenchArgs(argsman);
    SHA256AutoDetect();
    std::string error;
    if (!argsman.ParseParameters(argc, argv, error)) {
        tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
        return EXIT_FAILURE;
    }

    if (HelpRequested(argsman)) {
        std::cout << "Usage:  bench_bitcoin [options]\n"
                     "\n"