BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmt_throughputbenchmarkresult

Detailed Description

Outline

Purpose

Provide result repository for throughput performance test harness.

Classes

See also
bslmt_throughputbenchmark

Description

This component defines a mechanism, bslmt::ThroughputBenchmarkResult, which represents counts of the work done by each thread, thread group, and sample, divided by the number of actual seconds that the sample took to execute. Each specific result can be retrieved by calling getValue, and relevant percentiles can be retrieved using getMedian, getPercentile, getPercentiles, and getThreadPercentiles.

Usage

This section illustrates intended use of this component.

Example 1: Calculate Median and Percentiles

In the following example we populate a bslmt::ThroughputBenchmarkResult object and calculate median and percentiles.

First, we define a vector with thread group sizes:

bsl::vector<int> threadGroupSizes;
threadGroupSizes.resize(2);
threadGroupSizes[0] = 3;
threadGroupSizes[1] = 2;
Definition bslstl_vector.h:1025
void resize(size_type newSize)
Definition bslstl_vector.h:3616

Next, we define a bslmt::ThroughputBenchmarkResult with 10 samples and the previously defined thread group sizes:

bslmt::ThroughputBenchmarkResult myResult(10, threadGroupSizes);
Definition bslmt_throughputbenchmarkresult.h:140

Then, we populate the object with throughputs:

for (int tgId = 0; tgId < 2; ++tgId) {
for (int tId = 0; tId < myResult.numThreads(tgId); ++tId) {
for (int sId = 0; sId < 10; ++sId) {
double throughput = static_cast<double>(rand());
myResult.setThroughput(tgId, tId, sId, throughput);
}
}
}

Now, we calculate median of the first thread group and print it out:

double median;
myResult.getMedian(&median, 0);
bsl::cout << "Median of first thread group:" << median << "\n";

Finally, we calculate percentiles 0, 0.25, 0.5, 0.75, and 1.0 of the first thread group and print it out:

bsl::vector<double> percentiles(5);
myResult.getPercentiles(&percentiles, 0);
for (int i = 0; i < 5; ++i) {
bsl::cout << "Percentile " << 25 * i << "% is:"
<< percentiles[i] << "\n";
}