<commit_before>/*!
    \file launcher_console.cpp
    \brief Console launcher implementation
    \author <NAME>
    \date 16.07.2015
    \copyright MIT License
*/

#include "benchmark/launcher_console.h"

#include "benchmark/console.h"
#include "benchmark/reporter_console.h"
#include "benchmark/reporter_csv.h"
#include "benchmark/reporter_json.h"
#include "benchmark/version.h"

#include <iomanip>
#include <regex>

#include <OptionParser.h>

namespace CppBenchmark {

void LauncherConsole::Initialize(const int argc, char const* const* const argv)
{
    auto parser = optparse::OptionParser().version(version);

    const char* output[] = { "console", "csv", "json" };

    parser.add_option("-h", "--help").help("Show help");
    parser.add_option("-f", "--filter").help("Filter benchmarks by the given regexp pattern");
    parser.add_option("-l", "--list").action("store_true").help("List all avaliable benchmarks");
    parser.add_option("-o", "--output").choices(&output[0], &output[3]).set_default(output[0]).help("Output format (console, csv, json). Default: %default");
    parser.add_option("-q", "--quiet").action("store_true").help("Launch in quiet mode. No progress will be shown!");
    parser.add_option("-r", "--histograms").action("store").type("int").set_default(0).help("Create High Dynamic Range (HDR) Histogram files with a given resolution. Default: %default");

    optparse::Values options = parser.parse_args(argc, argv);

    // Check for double initialization
    if (_init)
    {
        parser.error("Console launcher double initialization!");
    }

    // Print help
    if (options.get("help"))
    {
        parser.print_help();
        parser.exit();
    }

    // Setup console launcher parameters
    _list = options.get("list");
    _silent = options.get("silent");
    _histograms = (int32_t)options.get("histograms");
    if (options.is_set("filter"))
        _filter = options["filter"];
    if (options.is_set("output"))
        _output = options["output"];

    // Update initialization flag
    _init = true;
}

void LauncherConsole::Execute()
{
    if (_list)
    {
        // List all suitable benchmarks
        std::regex matcher(_filter);<commit_msg>Submodule Sync<commit_after>/*!
    \file launcher_console.cpp
    \brief Console launcher implementation
    \author <NAME>
    \date 16.07.2015
    \copyright MIT License
*/

#include "benchmark/launcher_console.h"

#include "benchmark/console.h"
#include "benchmark/reporter_console.h"
#include "benchmark/reporter_csv.h"
#include "benchmark/reporter_json.h"
#include "benchmark/version.h"

#include <iomanip>
#include <regex>

#include <OptionParser.h>

namespace CppBenchmark {

void LauncherConsole::Initialize(const int argc, char const* const* const argv)
{
    auto parser = optparse::OptionParser().version(version);

    const char* output[] = { "console", "csv", "json" };

    parser.add_option("-h", "--help").help("Show help");
    parser.add_option("-f", "--filter").help("Filter benchmarks by the given regexp pattern");
    parser.add_option("-l", "--list").action("store_true").help("List all avaliable benchmarks");
    parser.add_option("-o", "--output").choices(&output[0], &output[3]).set_default(output[0]).help("Output format (console, csv, json). Default: %default");
    parser.add_option("-q", "--quiet").action("store_true").help("Launch in quiet mode. No progress will be shown!");
    parser.add_option("-r", "--histograms").action("store").type("int").set_default(0).help("Create High Dynamic Range (HDR) Histogram files with a given resolution. Default: %default");

    optparse::Values options = parser.parse_args(argc, argv);

    // Check for double initialization
    if (_init)
    {
        parser.error("Console launcher double initialization!");
    }

    // Print help
    if (options.get("help"))
    {
        parser.print_help();
        return 0;
    }

    // Setup console launcher parameters
    _list = options.get("list");
    _silent = options.get("silent");
    _histograms = (int32_t)options.get("histograms");
    if (options.is_set("filter"))
        _filter = options["filter"];
    if (options.is_set("output"))
        _output = options["output"];

    // Update initialization flag
    _init = true;
}

void LauncherConsole::Execute()
{
    if (_list)
    {
        // List all suitable benchmarks
        std::regex matcher(_filter);
{'fraction_non_alphanumeric': 0.16128298453139217, 'fraction_numerical': 0.0065969062784349405, 'mean_word_length': 3.7586580086580086, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7375521', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1322, 'n_words': 309}