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

Run previously added thread groups with sample&hyphen;level hooks&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
execute(
    xref:BloombergLP/bslmt/ThroughputBenchmarkResult.adoc[ThroughputBenchmarkResult]* result,
    int millisecondsPerSample,
    int numSamples,
    xref:BloombergLP/bslmt/ThroughputBenchmark/InitializeSampleFunction.adoc[InitializeSampleFunction] const& initializeFunctor,
    xref:BloombergLP/bslmt/ThroughputBenchmark/ShutdownSampleFunction.adoc[ShutdownSampleFunction] const& shutdownFunctor,
    xref:BloombergLP/bslmt/ThroughputBenchmark/CleanupSampleFunction.adoc[CleanupSampleFunction] const& cleanupFunctor);
----

== Description

Run the tests previously added with calls to the `addThreadGroup` method&period; The tests are run for the specified `numSamples` times&period; Each sample is run for the specified `millisecondsPerSample` duration&period; The results are stored in the specified `result` object&period; Specify `initializeFunctor`, which is run at the beginning of the sample and accepts a boolean flag `isFirst`, that is set to `true` on the first sample, and `false` otherwise&period; Specify `shutdownFunctor`, which is run at the end of each sample before threads have been joined, and accepts a boolean flag `isLast`, that is set to `true` on the last sample, and `false` otherwise&period; Specify `cleanupFunctor`, which is run at the end of each sample after threads have been joined, and accepts a boolean flag `isLast`, that is set to `true` on the last sample, and `false` otherwise&period; The behavior is undefined unless `0 &lt; millisecondsPerSample`, `0 &lt; numSamples`, and `0 &lt; numThreadGroups()`&period; Also see &lsqb;&rsqb;of a Test)&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *result*
| repository that receives the sample throughputs
| *millisecondsPerSample*
| duration of each sample in milliseconds
| *numSamples*
| number of times the test is executed
| *initializeFunctor*
| functor run at the start of each sample
| *shutdownFunctor*
| functor run before joining sample threads
| *cleanupFunctor*
| functor run after joining sample threads
|===


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