BenchmarkAnalyzer#
-
class numpy::BenchmarkAnalyzer#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use BenchmarkAnalyzer
BenchmarkAnalyzer obj;
// ... operations ...
Math Operations#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_BENCHMARK_SORTING.H:486 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_BENCHMARK_SORTING.H:437 |
|
|
void |
NP_BENCHMARK_SORTING.H:391 |
Code Examples#
The following examples are extracted from the test suite.
print_summary (np_test_1_all.cpp:20024)
20014 operation();
20015 auto end = std::chrono::high_resolution_clock::now();
20016 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
20017 times.push_back(duration.count() / 1000.0); // Convert to milliseconds
20018 }
20019
20020 void add_error(double error) {
20021 errors.push_back(error);
20022 }
20023
20024 void print_summary() {
20025 if (times.empty()) return;
20026
20027 double avg_time = std::accumulate(times.begin(), times.end(), 0.0) / times.size();
20028 double max_time = *std::max_element(times.begin(), times.end());
20029 double min_time = *std::min_element(times.begin(), times.end());
20030
20031 std::cout << "Benchmark: " << test_name << std::endl;
20032 // std::cout << " Average time: " << std::fixed << std::setprecision(3) << avg_time << " ms" << std::endl;
20033 // std::cout << " Min/Max time: " << min_time << "/" << max_time << " ms" << std::endl;