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

histogramBins from class fcf::NTest::DurationBasic::BeginOptions

Property: histogramBins = -1

Type: size_t

Class: fcf::NTest::DurationBasic::BeginOptions

Package: fcfTest

File: test.hpp ( link_to_the_declaration_in_the_file )

Available from version: 1.2.5

The number of bins to use for the duration histogram.

The histogramBins property defines the granularity of the duration histogram. It determines how many discrete intervals (bins) the total measured range will be divided into.

A higher number of bins provides a more detailed view of the distribution (higher resolution), while a lower number provides a more generalized overview. This is particularly useful for identifying outliers or understanding the variance in execution times.

Example: Configuring Histogram Granularity

Demonstrating how to set the histogramBins property to control the resolution of the collected timing data.

#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(5)); } FCF_TEST_DEFINE("HistogramDemo", "Statistics", "Binning") { fcf::NTest::DurationBasic<fcf::NTest::SteadyClock> duration; // 1. Configure the BeginOptions fcf::NTest::Duration::BeginOptions options; // 2. Set the number of bins for the histogram to 15 options.histogramBins = 15; // 3. Execute workload for(int i = 0; i < 100; ++i) { duration.begin(options, 0); simulate_work(); duration.end(0, -1); } // 4. Check the histogram fcf::NTest::log() << duration.histogram(0).toBarChart() << std::endl; fcf::NTest::log() << duration.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: "HistogramDemo" -> "Statistics" -> "Binning" ... > | > | > | > | > ||| | || > |||| | ||| > |||| ||||| > |||||||||||| > ||||||||||||| > ||||||||||||| | > ═══════════════ > OX (value): [0.005`058`889 : 0.005`158`594]; Step: 6647.00 > OY (count): [0 : 17]; Step: 1.70 > > ╔════╦═════════════════════════════════╦═══════╗ > ║ # ║ values ║ count ║ > ╠════╬═════════════════════════════════╬═══════╣ > ║ 1 ║ [0.005`058`889 : 0.005`065`535] ║ 9 ║ > ║ 2 ║ [0.005`065`536 : 0.005`072`182] ║ 10 ║ > ║ 3 ║ [0.005`072`183 : 0.005`078`829] ║ 9 ║ > ║ 4 ║ [0.005`078`830 : 0.005`085`476] ║ 8 ║ > ║ 5 ║ [0.005`085`477 : 0.005`092`123] ║ 5 ║ > ║ 6 ║ [0.005`092`124 : 0.005`098`770] ║ 9 ║ > ║ 7 ║ [0.005`098`771 : 0.005`105`417] ║ 6 ║ > ║ 8 ║ [0.005`105`418 : 0.005`112`064] ║ 7 ║ > ║ 9 ║ [0.005`112`065 : 0.005`118`711] ║ 9 ║ > ║ 10 ║ [0.005`118`712 : 0.005`125`358] ║ 17 ║ > ║ 11 ║ [0.005`125`359 : 0.005`132`005] ║ 4 ║ > ║ 12 ║ [0.005`132`006 : 0.005`138`652] ║ 4 ║ > ║ 13 ║ [0.005`138`653 : 0.005`145`299] ║ 2 ║ > ║ 14 ║ [0.005`145`300 : 0.005`151`946] ║ 0 ║ > ║ 15 ║ [0.005`151`947 : 0.005`158`594] ║ 1 ║ > ╚════╩═════════════════════════════════╩═══════╝ > [SUCCESS] Test completed successfully (0.510`685`073 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.510`685`073 sec