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

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

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

Class: fcf::NTest::DurationBasic

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Ends a measurement session at a specific level.

The end method marks the end of a measurement session. It calculates the elapsed time since the corresponding begin call was made.

It supports multiple signatures:

  • Single Level: Ends the measurement for a single level index.
  • Level Range: Ends measurements for all levels from a_beginLevel up to (but not including) a_endLevel.

Arguments

int a_beginLevel
- The starting level index for ending the measurement.

int a_endLevel
- The ending level index (exclusive).

Example: Ending a Measurement

Demonstrating how to end a measurement session.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <thread> #include <chrono> FCF_TEST_DEFINE("Bench", "Level", "BeginTest") { fcf::NTest::Duration bench(100); // Start measurement at level 0 bench.begin(0); // Perform work std::this_thread::sleep_for(std::chrono::seconds(1)); bench.end(0); fcf::NTest::log() << "Measurement finished." << std::endl; fcf::NTest::log() << " Duration: " << bench.duration(0) << 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" -> "Level" -> "BeginTest" ... > Measurement finished. > Duration: 1.000090518 [SUCCESS] Test completed successfully (1.000`143`731 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 1.000`143`731 sec