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

reset() method from fcf::NTest::DurationBasic class

void reset(int a_beginLevel = 0)
void reset(int a_beginLevel, int a_endLevel)

Class: fcf::NTest::DurationBasic

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Resets measurements for a specific range of levels.

The reset method clears all recorded data (durations, iterations, histograms) for the specified measurement levels.

If the a_endLevel parameter is not specified, the function applies the values ​​to only one level (a_beginLevel).

Arguments

int a_beginLevel
- The starting level index to reset.

int a_endLevel
- The ending level index. If -1, all levels are reset.

Example: Resetting Measurements

Clearing data to start a new measurement phase.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <thread> #include <chrono> FCF_TEST_DEFINE("Bench", "Reset", "ResetTest") { fcf::NTest::Duration bench(10); bench.begin(); std::this_thread::sleep_for(std::chrono::seconds(1)); bench.end(); bench.begin(); std::this_thread::sleep_for(std::chrono::seconds(1)); bench.end(); fcf::NTest::log() << "Current duration: " << bench.duration() << std::endl; bench.reset(0, -1); bench.begin(); std::this_thread::sleep_for(std::chrono::seconds(1)); bench.end(); fcf::NTest::log() << "Current duration after reset: " << bench.duration() << std::endl; } 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: "Bench" -> "Reset" -> "ResetTest" ... > Current duration: 2.000261047 > Current duration after reset: 1.000076972 [SUCCESS] Test completed successfully (3.000`451`152 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 3.000`451`152 sec