[CONSTRUCTOR]
Duration(
unsigned long long a_iterations)
Class: fcf::NTest::Duration
Package: fcfTest
File: test.hpp
Available from version: 1.0.1
Initializes a duration object with a specific number of iterations for benchmarking
The fcf::NTest::Duration class provides two ways to initialize a benchmarking session:
1. Parameterized Constructor
Duration(unsigned long long a_iterations)
Sets the exact number of times the workload will be executed during the benchmarking process.
2. Default Constructor
Duration()
Sets the number of iterations to 1. Useful for single-shot measurements.
Arguments
unsigned long long a_iterations
- The set value of the number of repetitions of the measured actions
Example: High-iteration Benchmarking
Used when measuring very fast operations where many iterations are required to get a stable average
fcf::NTest::Duration bench(1000000); // 1 million iterations
bench([]() {
// Fast operation
int x = 1 + 1;
});
fcf::NTest::log() << "Average time: " << bench.duration().count() << " ns" << std::endl;
Example: Single-shot Measurement
Used for long-running tasks where only one execution is needed
fcf::NTest::Duration bench; // Default: 1 iteration
bench.begin();
// Long-running task
std::this_thread::sleep_for(std::chrono::milliseconds(100));
bench.end();
fcf::NTest::log() << "Total time: " << bench.totalDuration().count() << " ns" << std::endl;