Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
benchmarks.cpp
Go to the documentation of this file.
1
25#include "apps/benchmarks.hpp"
26
28const std::vector<size_t> n_samples_vector = {10'000, 50'000, 100'000, 500'000, 1'000'000};
29
31unsigned int n_threads;
32
49void saveResults(const std::string &filename, const std::vector<results> &results, const std::string &function_expr) {
50 std::ofstream outfile;
51 outfile.open(filename);
52
53 if (!outfile.is_open()) {
54 std::cerr << "Error: Unable to create results file " << filename << std::endl;
55 return;
56 }
57
58 // Header: Function description and columns
59 outfile << "Function: " << function_expr << "\n";
60 outfile << "Number of points\tIntegration Result\tDuration (ms)\n";
61
62 for (const auto &result : results) {
63 outfile << result.n_samples << "\t"
64 << result.integration_result << "\t"
65 << result.duration << "\n";
66 }
67 outfile.close();
68}
69
void saveResults(const std::string &filename, const std::vector< results > &results, const std::string &function_expr)
Export benchmark results to CSV file for analysis.
const std::vector< size_t > n_samples_vector
Global sample count vector used across all benchmarks for convergence testing.
unsigned int n_threads
Global OpenMP thread count (set at runtime)
Benchmarking framework for Monte Carlo integration algorithms.
Stores benchmark result for a single sample count.