text
stringlengths
0
2.2M
* limitations under the License.
*/
#include <folly/Benchmark.h>
#include <folly/experimental/settings/Settings.h>
#include <folly/init/Init.h>
/*
============================================================================
folly/experimental/settings/test/SettingsBenchmarks.cpprelative time/iter
iters/s
============================================================================
settings_get_bench 1.73ns 577.36M
============================================================================
*/
FOLLY_SETTING_DEFINE(follytest, benchmarked, int, 100, "desc");
BENCHMARK(settings_get_bench, iters) {
for (unsigned int i = 0; i < iters; ++i) {
auto value = *FOLLY_SETTING(follytest, benchmarked);
folly::doNotOptimizeAway(value);
}
}
int main(int argc, char** argv) {
folly::init(&argc, &argv);
folly::runBenchmarks();
return 0;
}
// bslmt_qlock.t.cpp -*-C++-*-
// ----------------------------------------------------------------------------
// NOTICE
//
// This component is not up to date with current BDE coding standards, and
// should not be used as an example for new development.
// ----------------------------------------------------------------------------
#include <bslmt_qlock.h>
#include <bslmt_barrier.h>
#include <bslmt_lockguard.h>
#include <bslmt_mutex.h>
#include <bslmt_threadattributes.h>
#include <bslmt_threadutil.h>
#include <bslmt_semaphore.h>
#include <bslim_testutil.h>
#include <bsls_atomicoperations.h>
#include <bsls_stopwatch.h>
#include <bsls_timeutil.h>
#include <bsl_iostream.h>
#include <bsl_string.h>
#include <bsl_vector.h>
#include <bsl_cstdlib.h> // 'atoi'
#include <bsl_cstring.h> // 'strcmp'
#include <bsl_c_stdlib.h> // 'rand_r'
using namespace BloombergLP;
using namespace bsl; // automatically added by script
//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
// Overview
// --------
// The basic idea of testing bslmt::QLock and bslmt::QLock is to create thread
// poll and manipulate various test data in parallel, then to check that the
// integrity of data is preserved.
//
// The helper class MyTask provides thread pool and its management. This class
// creates thread pool, executes in each thread specified function and join all
// threads to make sure that there are no unfinished threads left and there is
// no leak of resources. The class also is a convenient place holder to common
// data used by thread function.
//
// The helper class Rand provides generation of pseudo-random numbers for each
// thread.
//-----------------------------------------------------------------------------
// CLASS bslmt::QLock CLASS bslmt::QLockGuard
// [ 5] Contention test: many threads - many bslmt::QLocks
// [ 4] Test of internal QLock core primitives:
// setFlag and waitOnFlag
// [ 3] Aggressive contention test: many threads - one bslmt::QLock
// [ 2] USAGE EXAMPLE: MT-Safe Singleton.
// Design is based on combination of bsls::AtomicInt
// and bslmt_QLocks.
// [ 1] BREATHING TEST
// ============================================================================
// STANDARD BDE ASSERT TEST FUNCTION
// ----------------------------------------------------------------------------