text stringlengths 0 2.2M |
|---|
if (!(X)) { cout << #I << ": " << I << "\t" << #J << ": " << J << "\t" << \
|
#K << ": " << K << "\t" << #L << ": " << L << "\n"; \
|
aSsErT(1, #X, __LINE__); } }
|
#define LOOP0_ASSERT ASSERT
|
#define LOOP1_ASSERT LOOP_ASSERT
|
//=============================================================================
|
// STANDARD BDE VARIADIC ASSERT TEST MACROS
|
//-----------------------------------------------------------------------------
|
#define NUM_ARGS_IMPL(X5, X4, X3, X2, X1, X0, N, ...) N
|
#define NUM_ARGS(...) NUM_ARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1, 0, "")
|
#define LOOPN_ASSERT_IMPL(N, ...) LOOP ## N ## _ASSERT(__VA_ARGS__)
|
#define LOOPN_ASSERT(N, ...) LOOPN_ASSERT_IMPL(N, __VA_ARGS__)
|
#define ASSERTV(...) LOOPN_ASSERT(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
|
// ============================================================================
|
// SEMI-STANDARD TEST OUTPUT MACROS
|
// ----------------------------------------------------------------------------
|
#define P(X) cout << #X " = " << (X) << endl; // Print identifier and value.
|
#define Q(X) cout << "<| " #X " |>" << endl; // Quote identifier literally.
|
#define P_(X) cout << #X " = " << (X) << ", " << flush; // 'P(X)' without '\n'
|
#define T_ cout << "\t" << flush; // Print tab w/o newline.
|
#define L_ __LINE__ // current Line number
|
// ============================================================================
|
// NEGATIVE-TEST MACRO ABBREVIATIONS
|
// ----------------------------------------------------------------------------
|
#define ASSERT_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_PASS(EXPR)
|
#define ASSERT_SAFE_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_SAFE_FAIL(EXPR)
|
#define ASSERT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_FAIL(EXPR)
|
#define ASSERT_OPT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPR)
|
//=============================================================================
|
// GLOBAL TYPEDEFS/CONSTANTS FOR TESTING
|
//-----------------------------------------------------------------------------
|
typedef balb::RateLimiter Obj;
|
typedef bsls::TimeInterval Ti;
|
typedef bsls::Types::Uint64 Uint64;
|
typedef unsigned int uint;
|
//=============================================================================
|
// USAGE EXAMPLE
|
//-----------------------------------------------------------------------------
|
///Usage
|
///-----
|
// This section illustrates the intended use of this component.
|
//
|
///Example 1: Controlling Network Traffic Generation
|
///-------------------------------------------------
|
// Suppose that we want to send data over a network interface with the load
|
// spike limitations explained below:
|
//
|
//: o The long term average rate of resource usage (i.e., the sustained rate)
|
//: should not exceed 1024 bytes/s ('Rs').
|
//:
|
//: o The period over which to monitor the long term average rate (i.e., the
|
//: sustained-rate time-window) should be 0.5s ('Wp').
|
//:
|
//: o The peak resource usage (i.e., the peak rate) should not exceed 2048
|
//: bytes/s ('Rp').
|
//:
|
//: o The period over which to monitor the peak resource usage should be
|
//: 0.0625s (Wp).
|
//
|
// This is shown in Figure 2 below.
|
//..
|
// Fig. 2:
|
//
|
// ^ Rate (Units per second)
|
// | _____ .
|
// | / B \ .
|
// 2048|---------------------------/-------\--------Rp (Maximum peak rate)
|
// | __ / \ .
|
// | / \ / A2 \ .
|
// | / A1 \ / \ .
|
// 1024|--------/------\ ------/---------------\----Rs (Maximum sustained rate)
|
// | __ / \ / \__.
|
// |__/ \/ \___/ .
|
// | .
|
// --------------------------------------------->
|
// T (seconds)
|
//..
|
// Notice that we can understand the limitations imposed by the rate-limiter
|
// graphically as the maximum area above the respective lines, 'Rp' and 'Rs',
|
// that the usage curve to allowed to achieve. In the example above:
|
//
|
// o The area above the sustained rate 'Rs' (e.g., 'A1' or 'A2+B') should
|
// contain no more than 512 bytes.
|
//
|
// o The area above the peak rate 'Rp' should contain no more than 128 bytes.
|
//
|
// Further suppose that we have a function, 'sendData', that transmits a
|
// specified amount of data over that network:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.