ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
Benchmark.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include "cli/CLIOptions.hpp"
11
12#include <nlohmann/json.hpp>
13#include <string>
14#include <vector>
15#include <optional>
16#include <functional>
17
18namespace CLI {
19 class App;
20}
21
22namespace ppforest2::cli {
24 CLI::App* setup_benchmark(CLI::App& app, CLIOptions& params);
25
44 float cv = 0.05f;
46 int window = 3;
48 int min = 10;
50 int max = 200;
51 };
52
56 struct Scenario {
57 std::string name;
58
59 // Data source: either a CSV path or simulated NxPxG
60 std::string data;
61
62 // Data parameters (used for simulation; ignored when data is set)
63 int n = 1000;
64 int p = 10;
65 int g = 3;
66
67 // Model parameters
68 int size = 100;
69 float vars = 0.5f;
70 float lambda = 0.5f;
71 int threads = -1;
72
73 // Evaluation parameters
74 float train_ratio = 0.7f;
75 int seed = 0;
76 int warmup = 0;
77
78 // Iteration mode: if iterations > 0, fixed mode; otherwise convergence
79 int iterations = -1;
81 };
82
89 std::string name;
90 std::string data;
91
92 // Data shape (copied from scenario for reporting; 0 for real-data scenarios)
93 int n = 0, p = 0, g = 0;
94 int size = 0;
95 float vars = 0;
96 float train_ratio = 0.7f;
97
98 // Aggregated metrics
99 int runs = 0;
100 double mean_time_ms = 0;
101 double std_time_ms = 0;
102 double mean_tr_error = 0;
103 double mean_te_error = 0;
104 long peak_rss_bytes = -1;
105 double peak_rss_mb = -1;
106
107 // Scenario wall-clock time (including warmup + process overhead)
109 };
110
115 std::string name = "ppforest2 benchmark";
116 std::vector<Scenario> scenarios;
117 };
118
122 struct SuiteResult {
123 std::string suite_name;
124 std::string timestamp;
125 std::vector<ScenarioResult> results;
126 double total_time_ms = 0;
127
128 nlohmann::json to_json() const;
129 };
130
135 BenchmarkSuite parse_suite(std::string const& path);
136
141 BenchmarkSuite parse_suite(nlohmann::json const& j);
142
146 SuiteResult parse_results(std::string const& path);
147
154 using ProgressCallback = std::function<void(int scenario_index, int total, std::string const& name)>;
155
169 std::string const& binary_path,
170 bool quiet = false,
171 ProgressCallback progress = nullptr);
172
176 ScenarioResult run_scenario(Scenario const& scenario, std::string const& binary_path, bool quiet = false);
177
184 int run_benchmark(CLIOptions& params, std::string const& binary_path);
185}
CLI argument parsing, validation, and configuration for ppforest2.
Definition Benchmark.hpp:18
Command-line interface: argument parsing, subcommands, and benchmark/evaluation orchestration.
Definition Benchmark.hpp:22
CLI::App * setup_benchmark(CLI::App &app, CLIOptions &params)
Register benchmark subcommand options on app.
BenchmarkSuite parse_suite(std::string const &path)
Parse a BenchmarkSuite from a JSON file path.
ScenarioResult run_scenario(Scenario const &scenario, std::string const &binary_path, bool quiet=false)
Run a single scenario as a subprocess.
SuiteResult parse_results(std::string const &path)
Parse a SuiteResult from a JSON file (for baseline comparison).
int run_benchmark(CLIOptions &params, std::string const &binary_path)
Run the benchmark subcommand.
SuiteResult run_suite(BenchmarkSuite const &suite, std::string const &binary_path, bool quiet=false, ProgressCallback progress=nullptr)
Run all scenarios in a suite via subprocess invocations.
std::function< void(int scenario_index, int total, std::string const &name)> ProgressCallback
Callback for progress reporting during benchmark execution.
Definition Benchmark.hpp:154
A suite of scenarios with shared defaults.
Definition Benchmark.hpp:114
std::vector< Scenario > scenarios
Definition Benchmark.hpp:116
std::string name
Definition Benchmark.hpp:115
All CLI options and runtime parameters.
Definition CLIOptions.hpp:32
Convergence criteria for adaptive stopping in benchmarks.
Definition Benchmark.hpp:42
int max
Definition Benchmark.hpp:50
int min
Definition Benchmark.hpp:48
float cv
Definition Benchmark.hpp:44
int window
Definition Benchmark.hpp:46
Result of running a single benchmark scenario.
Definition Benchmark.hpp:88
double scenario_time_ms
Definition Benchmark.hpp:108
double std_time_ms
Definition Benchmark.hpp:101
int n
Definition Benchmark.hpp:93
int runs
Definition Benchmark.hpp:99
long peak_rss_bytes
Definition Benchmark.hpp:104
std::string name
Definition Benchmark.hpp:89
double mean_te_error
Definition Benchmark.hpp:103
std::string data
Definition Benchmark.hpp:90
float train_ratio
Definition Benchmark.hpp:96
int size
Definition Benchmark.hpp:94
float vars
Definition Benchmark.hpp:95
double mean_time_ms
Definition Benchmark.hpp:100
int p
Definition Benchmark.hpp:93
double mean_tr_error
Definition Benchmark.hpp:102
double peak_rss_mb
Definition Benchmark.hpp:105
int g
Definition Benchmark.hpp:93
A single benchmark scenario: data shape + model config.
Definition Benchmark.hpp:56
int iterations
Definition Benchmark.hpp:79
float lambda
Definition Benchmark.hpp:70
int warmup
Definition Benchmark.hpp:76
std::string data
Definition Benchmark.hpp:60
ConvergenceCriteria convergence
Definition Benchmark.hpp:80
int threads
Definition Benchmark.hpp:71
std::string name
Definition Benchmark.hpp:57
int size
Definition Benchmark.hpp:68
int n
Definition Benchmark.hpp:63
int g
Definition Benchmark.hpp:65
int p
Definition Benchmark.hpp:64
float train_ratio
Definition Benchmark.hpp:74
float vars
Definition Benchmark.hpp:69
int seed
Definition Benchmark.hpp:75
Aggregated results for an entire suite run.
Definition Benchmark.hpp:122
nlohmann::json to_json() const
std::string timestamp
Definition Benchmark.hpp:124
double total_time_ms
Definition Benchmark.hpp:126
std::vector< ScenarioResult > results
Definition Benchmark.hpp:125
std::string suite_name
Definition Benchmark.hpp:123