[#BloombergLP-bslmt-ThroughputBenchmark] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::ThroughputBenchmark :relfileprefix: ../../ :mrdocs: Mechanism for multi‐threaded throughput performance testing. == Synopsis Declared in `<bslmt_throughputbenchmark.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class ThroughputBenchmark; ---- == Description 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. == 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`] | Alias for a functor that cleans up after a sample has finished. | 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`] | Alias for a functor that initializes a sample before threads start. | 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`] | Alias for the per‐thread function executed during a benchmark sample. | xref:BloombergLP/bslmt/ThroughputBenchmark/ShutdownSampleFunction.adoc[`ShutdownSampleFunction`] | Alias for a functor that shuts down a sample before threads are joined. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThroughputBenchmark/2constructor.adoc[`ThroughputBenchmark`] [.small]#[constructor]# | Create an empty `ThroughputBenchmark` object. | 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`. | xref:BloombergLP/bslmt/ThroughputBenchmark/busyWork.adoc[`busyWork`] | Perform arithmetic operations to consume an amount of time in linear relation to the specified `busyWorkAmount`. | 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`. |=== == 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]#