text stringlengths 0 2.2M |
|---|
// --------------------------------------------------------------------
|
// CLASS METHOD 'resetStatistics'
|
//
|
// Concerns:
|
//: 1 'resetStatistics' resets unit statistics counter to 0.
|
//:
|
//: 2 'resetStatistics' updates 'statisticsCollectionStartTime' time
|
//: correctly.
|
//:
|
//: 3 'resetStatistics' does not alter object state except for
|
//: submitted units counter and 'lastReset' time.
|
//
|
// Testing:
|
// void resetStatistics();
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "CLASS METHOD 'resetStatistics'" << endl
|
<< "==========================" << endl;
|
Uint64 usedUnits = 0;
|
Uint64 unusedUnits = 0;
|
const Ti CREATION_TIME = Ti(0.0);
|
const Ti UPD_TIME = Ti(0.75);
|
const Uint64 UNITS = 500;
|
const Uint64 S_RATE = 1000;
|
const Ti S_WND = Ti(10);
|
const Uint64 P_RATE = 10000;
|
const Ti P_WND = Ti(0.1);
|
const Uint64 EXP_USED = UNITS;
|
const Uint64 EXP_UNUSED =
|
(Uint64) floor((UPD_TIME - CREATION_TIME).totalSecondsAsDouble() *
|
S_RATE) - EXP_USED;
|
Obj x(S_RATE, S_WND, P_RATE, P_WND, CREATION_TIME);
|
x.submit(UNITS);
|
x.reserve(UNITS*2);
|
x.updateState(UPD_TIME);
|
x.getStatistics(&usedUnits, &unusedUnits);
|
ASSERT(EXP_USED == usedUnits);
|
ASSERT(EXP_UNUSED == unusedUnits);
|
ASSERT(CREATION_TIME == x.statisticsCollectionStartTime());
|
x.submit(UNITS);
|
x.resetStatistics();
|
// C-1
|
x.getStatistics(&usedUnits, &unusedUnits);
|
ASSERT(0 == usedUnits);
|
ASSERT(0 == unusedUnits);
|
// C-2
|
ASSERT(UPD_TIME == x.statisticsCollectionStartTime());
|
// C-3
|
ASSERT(S_RATE == x.sustainedRateLimit());
|
ASSERT(S_WND == x.sustainedRateWindow());
|
ASSERT(P_RATE == x.peakRateLimit());
|
ASSERT(P_WND == x.peakRateWindow());
|
ASSERT(UPD_TIME == x.lastUpdateTime());
|
ASSERT(UNITS*2 == x.unitsReserved());
|
} break;
|
case 9: {
|
// --------------------------------------------------------------------
|
// CLASS METHOD 'getStatistics'
|
//
|
// Concerns:
|
//: 1 'getStatistics' returns 0 for a new object, created by value
|
//: CTOR.
|
//:
|
//: 2 'getStatistics' returns correct numbers of used and unused units
|
//: (the calculation is base upon the sustained rate sustained rate
|
//: after a sequence of 'submit' and 'updateState' calls.
|
//:
|
//: 3 Specifying invalid parameters for 'getStatistics()' causes
|
//: certain behavior in special build configuration.
|
//:
|
//: 4 Statistics is calculated for interval between
|
//: 'statisticsCollectionStartTime' and 'lastUpdateTime'
|
//
|
// Testing:
|
// void getStatistics(*submittedUnits, *unusedUnits) const;
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "CLASS METHOD 'getStatistics'" << endl
|
<< "============================" << endl;
|
Uint64 usedUnits = 0;
|
Uint64 unusedUnits = 0;
|
// C-1
|
if (verbose) cout << endl
|
<< "Testing: statistics after value construction"
|
<< endl;
|
{
|
Obj x(1000, Ti(1), 10000, Ti(0.01), Ti(42.4242));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.