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

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

const fcf::NTest::HistogramBasic<fcf::NTest::TimeDuration, unsigned long long>& histogram(size_t a_level = 0) const
fcf::NTest::HistogramBasic<fcf::NTest::TimeDuration, unsigned long long>& histogram(size_t a_level = 0)

Class: fcf::NTest::DurationBasic

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Provides access to the histogram of the measurement distribution.

The histogram method returns a reference to the fcf::NTest::HistogramBasic object used to store the distribution of durations for a specific level.

Arguments

size_t a_level = 0
- The index of the measurement level.
Result
fcf::NTest::HistogramBasic<fcf::NTest::TimeDuration, unsigned long long>&
- A reference to the histogram for the specified level.

Example: Accessing the Histogram

Demonstrating how to retrieve the histogram to perform statistical analysis.

#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::log() << "Histogram:" << std::endl; fcf::NTest::log() << bench.histogram(0).toBarChart() << std::endl; fcf::NTest::log() << "Table:" << std::endl; fcf::NTest::log() << bench.histogram(0).toTable() << 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" ... > Histogram: > | > || > || | > || | > |||| > |||| > ||||| > ||||| > ||||| > ||||||||| > ══════════ > OX (value): [0.001`025`693 : 0.001`179`774]; Step: 15408.10 > OY (count): [1 : 269]; Step: 26.80 > > Table: > ╔════╦═════════════════════════════════╦═══════╗ > ║ # ║ values ║ count ║ > ╠════╬═════════════════════════════════╬═══════╣ > ║ 1 ║ [0.001`025`693 : 0.001`041`100] ║ 6 ║ > ║ 2 ║ [0.001`041`101 : 0.001`056`508] ║ 15 ║ > ║ 3 ║ [0.001`056`509 : 0.001`071`916] ║ 240 ║ > ║ 4 ║ [0.001`071`917 : 0.001`087`324] ║ 269 ║ > ║ 5 ║ [0.001`087`325 : 0.001`102`733] ║ 148 ║ > ║ 6 ║ [0.001`102`734 : 0.001`118`141] ║ 214 ║ > ║ 7 ║ [0.001`118`142 : 0.001`133`549] ║ 94 ║ > ║ 8 ║ [0.001`133`550 : 0.001`148`957] ║ 11 ║ > ║ 9 ║ [0.001`148`958 : 0.001`164`365] ║ 2 ║ > ║ 10 ║ [0.001`164`366 : 0.001`179`774] ║ 1 ║ > ╚════╩═════════════════════════════════╩═══════╝ > [SUCCESS] Test completed successfully (1.089`613`013 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 1.089`613`013 sec