9#ifndef INCLUDED_BSLMT_THROUGHPUTBENCHMARK
10#define INCLUDED_BSLMT_THROUGHPUTBENCHMARK
154#include <bslscm_version.h>
168#include <bsl_functional.h>
169#include <bsl_vector.h>
174class ThroughputBenchmark_TestUtil;
266 static unsigned int s_antiOptimization;
290 bool isRunState()
const;
348 int millisecondsPerSample,
367 int millisecondsPerSample,
518bool ThroughputBenchmark::isRunState()
const
527 if (0 == d_threadGroups.size()) {
531 int numThreads = d_threadGroups[0].d_numThreads;
541 return static_cast<int>(d_threadGroups.size());
550 return d_threadGroups[threadGroupIndex].d_numThreads;
558 return d_threadGroups.get_allocator().mechanism();
589 return d_data.d_state;
596 return d_data.d_threadGroups;
Forward declaration.
Definition bslstl_function.h:934
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition bslmt_barrier.h:353
Definition bslmt_throughputbenchmarkresult.h:140
Definition bslmt_throughputbenchmark.h:482
~ThroughputBenchmark_TestUtil()=default
ThroughputBenchmark_TestUtil(ThroughputBenchmark &data)
Definition bslmt_throughputbenchmark.h:579
bsl::vector< ThroughputBenchmark::ThreadGroup > & threadGroups()
Definition bslmt_throughputbenchmark.h:594
bsls::AtomicInt & state()
Definition bslmt_throughputbenchmark.h:587
Definition bslmt_throughputbenchmark.h:451
void operator()()
Work function being run on the thread.
ThroughputBenchmark_WorkFunction(ThroughputBenchmark_WorkData &data)
Definition bslmt_throughputbenchmark.h:567
~ThroughputBenchmark_WorkFunction()=default
Definition bslmt_throughputbenchmark.h:189
bsl::function< void(bool)> ShutdownSampleFunction
Definition bslmt_throughputbenchmark.h:220
void execute(ThroughputBenchmarkResult *result, int millisecondsPerSample, int numSamples)
bsl::function< void()> InitializeThreadFunction
Definition bslmt_throughputbenchmark.h:235
bsl::function< void(bool)> CleanupSampleFunction
Definition bslmt_throughputbenchmark.h:228
int numThreadsInGroup(int threadGroupIndex) const
Definition bslmt_throughputbenchmark.h:545
int numThreadGroups() const
Return the number of thread groups.
Definition bslmt_throughputbenchmark.h:539
bsl::function< void()> CleanupThreadFunction
Definition bslmt_throughputbenchmark.h:242
bsl::function< void(bool)> InitializeSampleFunction
Definition bslmt_throughputbenchmark.h:211
static unsigned int antiOptimization()
ThroughputBenchmark(bslma::Allocator *basicAllocator=0)
void execute(ThroughputBenchmarkResult *result, int millisecondsPerSample, int numSamples, const InitializeSampleFunction &initializeFunctor, const ShutdownSampleFunction &shutdownFunctor, const CleanupSampleFunction &cleanupFunctor)
static bsls::Types::Int64 estimateBusyWorkAmount(bsls::TimeInterval duration)
BSLMF_NESTED_TRAIT_DECLARATION(ThroughputBenchmark, bslma::UsesBslmaAllocator)
int addThreadGroup(const RunFunction &runFunction, int numThreads, bsls::Types::Int64 busyWorkAmount, const InitializeThreadFunction &initializeFunctor, const CleanupThreadFunction &cleanupFunctor)
bslma::Allocator * allocator() const
Return the allocator used by this object.
Definition bslmt_throughputbenchmark.h:556
int addThreadGroup(const RunFunction &runFunction, int numThreads, bsls::Types::Int64 busyWorkAmount)
bsl::function< void(int)> RunFunction
Definition bslmt_throughputbenchmark.h:203
int numThreads() const
Return the total number of threads.
Definition bslmt_throughputbenchmark.h:525
static void busyWork(bsls::Types::Int64 busyWorkAmount)
Definition bsls_atomic.h:743
int loadAcquire() const
Definition bsls_atomic.h:1732
Definition bsls_timeinterval.h:301
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslmt_barrier.h:344
Definition bslma_usesbslmaallocator.h:343
Data used by a thread group.
Definition bslmt_throughputbenchmark.h:245
InitializeThreadFunction d_initialize
Definition bslmt_throughputbenchmark.h:257
CleanupThreadFunction d_cleanup
Definition bslmt_throughputbenchmark.h:260
int d_numThreads
Definition bslmt_throughputbenchmark.h:250
RunFunction d_func
Definition bslmt_throughputbenchmark.h:248
bsls::Types::Int64 d_amount
Definition bslmt_throughputbenchmark.h:253
Data transferred to ThroughputBenchmark_WorkFunction.
Definition bslmt_throughputbenchmark.h:398
ThroughputBenchmark::InitializeThreadFunction d_initialize
Definition bslmt_throughputbenchmark.h:407
bsls::Types::Int64 d_amount
Definition bslmt_throughputbenchmark.h:404
bslmt::Barrier * d_barrier_p
Definition bslmt_throughputbenchmark.h:427
bsls::Types::Int64 d_actualNanos
Definition bslmt_throughputbenchmark.h:433
int d_threadIndex
Definition bslmt_throughputbenchmark.h:420
ThroughputBenchmark::CleanupThreadFunction d_cleanup
Definition bslmt_throughputbenchmark.h:411
ThroughputBenchmark * d_bench_p
Definition bslmt_throughputbenchmark.h:415
bsls::Types::Int64 d_count
Definition bslmt_throughputbenchmark.h:438
ThroughputBenchmark::RunFunction d_func
Definition bslmt_throughputbenchmark.h:401
long long Int64
Definition bsls_types.h:132