FCF 2.0 development in progress...
> > > > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

measurementStep from class fcf::NTest::DurationBasic::Options

Property: measurementStep = -1

Type: size_t

Class: fcf::NTest::DurationBasic::Options

Package: fcfTest

File: test.hpp ( link_to_the_declaration_in_the_file )

Available from version: 1.2.5

The number of iterations to skip between consecutive measurements.

The measurementStep property defines the interval between measurements when performing multiple iterations. It allows you to skip a certain number of execution cycles between each recorded measurement point. This can be useful when code execution takes very little time.

For example, if iterations is set to 100 and measurementStep is set to 10, the system will perform measurements at regular intervals, reducing the overhead of data collection and focusing on a representative sample of the workload execution.

Example: Using Measurement Step to Sample Workload

Demonstrating how to use measurementStep to collect periodic samples during a long-running test.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> #include <thread> #include <chrono> void simulate_work() { std::this_thread::sleep_for(std::chrono::milliseconds(1)); } FCF_TEST_DEFINE("StepDemo", "Options", "MeasurementStep") { // 1. Configure the Options fcf::NTest::Duration::Options options; // Run 100 iterations in total options.iterations = 100; // Record a measurement every 10 iterations options.measurementStep = 10; fcf::NTest::Duration duration(options); // 2. Execute workload and measurement duration([](){ simulate_work(); }); // 3. Verify results fcf::NTest::log() << "Total iterations: " << duration.options().iterations << std::endl; fcf::NTest::log() << "Average duration: " << duration.average() << " sec" << std::endl; FCF_TEST(true); } int main(int a_argc, char* a_argv[]) { bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "StepDemo" -> "Options" -> "MeasurementStep" ... > Total iterations: 100 > Average duration: 0.001092867 sec [SUCCESS] Test completed successfully (0.109`357`132 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.109`357`132 sec