[#BloombergLP-bslmt-ThroughputBenchmark] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::ThroughputBenchmark :relfileprefix: ../../ :mrdocs: This class is a mechanism that provides performance testing for multi‐ threaded components. It allows running different thread functions at the same time, and simulates a work load between subsequent calls to the tested thread functions. The results are loaded into a `bslmt::ThroughputBenchmarkResult` object, which provides access to counts of the work done by each thread, thread group, and sample, divided by the number of actual seconds of execution. == Synopsis Declared in `<bslmt_throughputbenchmark.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class ThroughputBenchmark; ---- == Types [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThroughputBenchmark/ThreadGroup.adoc[`ThreadGroup`] | Data used by a thread group |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThroughputBenchmark/CleanupSampleFunction.adoc[`CleanupSampleFunction`] | An alias to a function meeting the following contract: ` /// Clean up after the sample run. If the specified `isLast` is /// `true`, this is the last sample run. void cleanupSample(bool isLast); ` | xref:BloombergLP/bslmt/ThroughputBenchmark/CleanupThreadFunction.adoc[`CleanupThreadFunction`] | An alias to a function meeting the following contract: ` /// Clean up after each thread in a sample run. void cleanupThread(); ` | xref:BloombergLP/bslmt/ThroughputBenchmark/InitializeSampleFunction.adoc[`InitializeSampleFunction`] | An alias to a function meeting the following contract: ` /// Initialize the sample run. If the specified `isFirst` is `true`, /// this is the first sample run. void initializeSample(bool isFirst); ` | xref:BloombergLP/bslmt/ThroughputBenchmark/InitializeThreadFunction.adoc[`InitializeThreadFunction`] | An alias to a function meeting the following contract: ` /// Initialize each thread in a sample run. void initializeThread(); ` | xref:BloombergLP/bslmt/ThroughputBenchmark/RunFunction.adoc[`RunFunction`] | An alias to a function meeting the following contract: ` /// Run the main part of the benchmark having the specified /// `threadIndex`. The behavior is undefined unless `threadIndex` is /// in the range `[0, numThreadsInGroup)]`, where `numThreadsInGroup` is /// the number of threads in a thread group for the associated /// throughput benchmark. void runTest(int threadIndex); ` | xref:BloombergLP/bslmt/ThroughputBenchmark/ShutdownSampleFunction.adoc[`ShutdownSampleFunction`] | An alias to a function meeting the following contract: ` /// Clean up at the end of the sample run, before threads have been /// joined. If the specified `isLast` is `true`, this is the last /// sample run. void shutdownSample(bool isLast); ` |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThroughputBenchmark/2constructor.adoc[`ThroughputBenchmark`] [.small]#[constructor]# | Create an empty `ThroughputBenchmark` object. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. | xref:BloombergLP/bslmt/ThroughputBenchmark/addThreadGroup-01.adoc[`addThreadGroup`] | `addThreadGroup` overloads | xref:BloombergLP/bslmt/ThroughputBenchmark/allocator.adoc[`allocator`] | Return the allocator used by this object. | xref:BloombergLP/bslmt/ThroughputBenchmark/execute-06.adoc[`execute`] | `execute` overloads | xref:BloombergLP/bslmt/ThroughputBenchmark/numThreadGroups.adoc[`numThreadGroups`] | Return the number of thread groups. | xref:BloombergLP/bslmt/ThroughputBenchmark/numThreads.adoc[`numThreads`] | Return the total number of threads. | xref:BloombergLP/bslmt/ThroughputBenchmark/numThreadsInGroup.adoc[`numThreadsInGroup`] | Return the number of threads in the specified `threadGroupIndex`. The behavior is undefined unless `0 <= threadGroupIndex < numThreadGroups()`. | xref:BloombergLP/bslmt/ThroughputBenchmark/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<ThroughputBenchmark, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThroughputBenchmark/antiOptimization.adoc[`antiOptimization`] | Return the value calculated by `busyWork`. Note that this method is provided to prevent the compiler from optimizing the simulated workload away. | xref:BloombergLP/bslmt/ThroughputBenchmark/busyWork.adoc[`busyWork`] | Perform arithmetic operations to consume an amount of time in linear relation to the specified `busyWorkAmount`. Note that the duration of `busyWork` invoked with a particular `busyWorkAmount` will vary with system load. | xref:BloombergLP/bslmt/ThroughputBenchmark/estimateBusyWorkAmount.adoc[`estimateBusyWorkAmount`] | Return an estimate of the work amount so that `busyWork` invoked with the returned work amount executes, approximately, for the specified `duration`. Note that this estimate varies with system load. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslmt/ThroughputBenchmark_TestUtil.adoc[BloombergLP::bslmt::ThroughputBenchmark_TestUtil]` | This class implements a test utility that gives the test driver access to the unexposed data members of `ThroughputBenchmark`. | `xref:BloombergLP/bslmt/ThroughputBenchmark_WorkFunction.adoc[BloombergLP::bslmt::ThroughputBenchmark_WorkFunction]` | This class is the work function functor, being called for each work thread. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#