Mechanism for multi‐threaded throughput performance testing.

Synopsis

Declared in <bslmt_throughputbenchmark.h>

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

Name

Description

ThreadGroup

Data used by a thread group

Type Aliases

Name

Description

CleanupSampleFunction

Alias for a functor that cleans up after a sample has finished.

CleanupThreadFunction

An alias to a function meeting the following contract: ` /// Clean up after each thread in a sample run. void cleanupThread(); `

InitializeSampleFunction

Alias for a functor that initializes a sample before threads start.

InitializeThreadFunction

An alias to a function meeting the following contract: ` /// Initialize each thread in a sample run. void initializeThread(); `

RunFunction

Alias for the per‐thread function executed during a benchmark sample.

ShutdownSampleFunction

Alias for a functor that shuts down a sample before threads are joined.

Member Functions

Name

Description

ThroughputBenchmark [constructor]

Create an empty ThroughputBenchmark object.

addThreadGroup

addThreadGroup overloads

allocator

Return the allocator used by this object.

execute

execute overloads

numThreadGroups

Return the number of thread groups.

numThreads

Return the total number of threads.

numThreadsInGroup

Return the number of threads in the specified threadGroupIndex. The behavior is undefined unless 0 <= threadGroupIndex < numThreadGroups().

operator BloombergLP::bslmf::NestedTraitDeclaration<ThroughputBenchmark, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Static Member Functions

Name

Description

antiOptimization

Return the value calculated by busyWork.

busyWork

Perform arithmetic operations to consume an amount of time in linear relation to the specified busyWorkAmount.

estimateBusyWorkAmount

Return an estimate of the work amount so that busyWork invoked with the returned work amount executes, approximately, for the specified duration.

Friends

Name

Description

BloombergLP::bslmt::ThroughputBenchmark_TestUtil

This class implements a test utility that gives the test driver access to the unexposed data members of ThroughputBenchmark.

BloombergLP::bslmt::ThroughputBenchmark_WorkFunction

This class is the work function functor, being called for each work thread.

Created with MrDocs