median() method from fcf::NTest::DurationBasic class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.5
Returns the median duration for a specific level using the internal histogram.
The
This method relies on the internal
Arguments
- The index of the measurement level.
Result
- The median duration recorded for the specified level.
Example: Calculating Median Duration
Demonstrating how to get the median time per iteration.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <thread>
#include <chrono>
FCF_TEST_DEFINE ("Bench", "Stats", "MedianTest") {
fcf::NTest::Duration bench(1000);
bench ([](){
std::this_thread::sleep_for(std::chrono::milliseconds(1));
});
fcf::NTest::TimeDuration med = bench.median (0);
fcf::NTest::log () << "Median duration: " << med.str (true) << std::endl;
fcf::NTest::log () << bench.histogram (0).toBarChart () << 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" -> "Stats" -> "MedianTest" ...
> Median duration: 0.001`065`381
> |
> || |
> || |
> || |
> ||||
> ||||
> |||||
> |||||
> |||||
> |||||||||
> ══════════
> OX (value): [0.001`026`521 : 0.001`182`526]; Step: 15600.50
> OY (count): [2 : 260]; Step: 25.80
>
[SUCCESS] Test completed successfully (1.091`778`701 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 1.091`778`701 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.