BenchmarkAnalyzer ================= .. cpp:class:: numpy::BenchmarkAnalyzer numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use BenchmarkAnalyzer BenchmarkAnalyzer obj; // ... operations ... Math Operations --------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void export_csv(const std::vector&results, const std::string &filename)`` - void - NP_BENCHMARK_SORTING.H:486 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void analyze_algorithm_performance(const std::vector&results)`` - void - NP_BENCHMARK_SORTING.H:437 - * - ``void print_summary(const std::vector&results)`` - void - NP_BENCHMARK_SORTING.H:391 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-benchmarkanalyzer-print_summary-0: .. dropdown:: print_summary (np_test_1_all.cpp:20024) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 20014 :emphasize-lines: 11 operation(); auto end = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast(end - start); times.push_back(duration.count() / 1000.0); // Convert to milliseconds } void add_error(double error) { errors.push_back(error); } void print_summary() { if (times.empty()) return; double avg_time = std::accumulate(times.begin(), times.end(), 0.0) / times.size(); double max_time = *std::max_element(times.begin(), times.end()); double min_time = *std::min_element(times.begin(), times.end()); std::cout << "Benchmark: " << test_name << std::endl; // std::cout << " Average time: " << std::fixed << std::setprecision(3) << avg_time << " ms" << std::endl; // std::cout << " Min/Max time: " << min_time << "/" << max_time << " ms" << std::endl;