[#BloombergLP-bslmt-ThroughputBenchmark]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::ThroughputBenchmark
:relfileprefix: ../../
:mrdocs:

Mechanism for multi&hyphen;threaded throughput performance testing&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;throughputbenchmark&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class ThroughputBenchmark;
----

== Description

This class is a mechanism that provides performance testing for multi&hyphen; threaded components&period; It allows running different thread functions at the same time, and simulates a work load between subsequent calls to the tested thread functions&period; The results are loaded into a `bslmt&colon;&colon;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&period;

== 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&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/CleanupThreadFunction.adoc[`CleanupThreadFunction`] 
| An alias to a function meeting the following contract&colon; &grave; &sol;&sol;&sol; Clean up after each thread in a sample run&period; void cleanupThread()&semi; &grave;
| xref:BloombergLP/bslmt/ThroughputBenchmark/InitializeSampleFunction.adoc[`InitializeSampleFunction`] 
| Alias for a functor that initializes a sample before threads start&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/InitializeThreadFunction.adoc[`InitializeThreadFunction`] 
| An alias to a function meeting the following contract&colon; &grave; &sol;&sol;&sol; Initialize each thread in a sample run&period; void initializeThread()&semi; &grave;
| xref:BloombergLP/bslmt/ThroughputBenchmark/RunFunction.adoc[`RunFunction`] 
| Alias for the per&hyphen;thread function executed during a benchmark sample&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/ShutdownSampleFunction.adoc[`ShutdownSampleFunction`] 
| Alias for a functor that shuts down a sample before threads are joined&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/ThroughputBenchmark/2constructor.adoc[`ThroughputBenchmark`]         [.small]#[constructor]#
| Create an empty `ThroughputBenchmark` object&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/addThreadGroup-01.adoc[`addThreadGroup`] 
| `addThreadGroup` overloads
| xref:BloombergLP/bslmt/ThroughputBenchmark/allocator.adoc[`allocator`] 
| Return the allocator used by this object&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/execute-06.adoc[`execute`] 
| `execute` overloads
| xref:BloombergLP/bslmt/ThroughputBenchmark/numThreadGroups.adoc[`numThreadGroups`] 
| Return the number of thread groups&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/numThreads.adoc[`numThreads`] 
| Return the total number of threads&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/numThreadsInGroup.adoc[`numThreadsInGroup`] 
| Return the number of threads in the specified `threadGroupIndex`&period; The behavior is undefined unless `0 &lt;&equals; threadGroupIndex &lt; numThreadGroups()`&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;ThroughputBenchmark, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/ThroughputBenchmark/antiOptimization.adoc[`antiOptimization`] 
| Return the value calculated by `busyWork`&period;
| xref:BloombergLP/bslmt/ThroughputBenchmark/busyWork.adoc[`busyWork`] 
| Perform arithmetic operations to consume an amount of time in linear relation to the specified `busyWorkAmount`&period;
| 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`&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bslmt/ThroughputBenchmark_TestUtil.adoc[BloombergLP::bslmt::ThroughputBenchmark&lowbar;TestUtil]`
| This class implements a test utility that gives the test driver access to the unexposed data members of `ThroughputBenchmark`&period;
| `xref:BloombergLP/bslmt/ThroughputBenchmark_WorkFunction.adoc[BloombergLP::bslmt::ThroughputBenchmark&lowbar;WorkFunction]`
| This class is the work function functor, being called for each work thread&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
