text
stringlengths 0
2.2M
|
---|
s.start(true);
|
int i;
|
for (i = 0; i <= MAX_GRANUALARITY; i += granularity) {
|
if (veryVerbose) { P(i) }
|
ASSERT(0 == Util::getRandomBytesNonBlocking(
|
buffer + granularity,
|
granularity));
|
}
|
s.stop();
|
LOOP2_ASSERT(granularity,
|
i,
|
0 != memcmp(buffer, prev_buffer, MAX_GRANUALARITY));
|
double time = s.accumulatedUserTime() + s.accumulatedSystemTime() +
|
s.accumulatedWallTime();
|
if (veryVerbose) { P_(granularity) P(time) }
|
s.reset();
|
}
|
} break;
|
case -4: {
|
// --------------------------------------------------------------------
|
// PERFORMANCE: 'getRandomBytes'
|
//
|
// Concerns:
|
// Measure the amount of time necessary to wait between successive
|
// request for random 'int'(s).
|
//
|
// Plan:
|
// Request a large number of random numbers to empty out the entropy
|
// source. Next request a random number and vary the delay before
|
// requesting another random number, each time measuring the time
|
// required to receive the next random number.
|
//
|
// Testing:
|
// PERFORMANCE: 'getRandomBytes'
|
//---------------------------------------------------------------------
|
if (verbose) cout << "PERFORMANCE: 'getRandomBytes'"
|
<< "=============================" << endl;
|
bsls::Stopwatch s;
|
const int MAX_SLEEP = 10;
|
int rand_int;
|
unsigned char *p1 = reinterpret_cast<unsigned char *>(&rand_int);
|
for (int i = 0; i < 15; ++i) {
|
if (veryVerbose) { P(i) }
|
ASSERT(0 == Util::getRandomBytes(p1, sizeof rand_int));
|
}
|
for (unsigned curr_sleep = 0; curr_sleep <= MAX_SLEEP; ++curr_sleep) {
|
if (veryVerbose) { P(curr_sleep) }
|
ASSERT(0 == Util::getRandomBytes(p1, sizeof rand_int));
|
sleep(curr_sleep);
|
s.start(true);
|
if (veryVerbose) { P(curr_sleep) }
|
ASSERT(0 == Util::getRandomBytes(p1, sizeof rand_int));
|
s.stop();
|
double time = s.accumulatedUserTime() + s.accumulatedSystemTime() +
|
s.accumulatedWallTime();
|
s.reset();
|
if (veryVerbose) {
|
cout << "Current Delay : " << curr_sleep
|
<< " ms" << endl
|
<< "Time to get next number: " << time * 100
|
<< " ms" << endl
|
<< "-------------------------" << endl << endl;
|
}
|
}
|
} break;
|
case -5: {
|
// --------------------------------------------------------------------
|
// PERFORMANCE: 'getRandomBytes'
|
//
|
// Concerns:
|
// Measure the amount of time required to acquire 'NUM_ITERATIONS'
|
// 'int'(s).
|
//
|
// Plan:
|
// Call 'RandomDevice::getRandomBytes' 'NUM_ITERATIONS' times, each
|
// time
|
// requesting a 'int'.
|
//
|
// Testing:
|
// PERFORMANCE: 'getRandomBytes'
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "PERFORMANCE: 'getRandomBytes'" << endl
|
<< "=============================" << endl;
|
bsls::Stopwatch s;
|
const int NUM_ITERATIONS = 15;
|
int rand_int;
|
unsigned char *p1 = reinterpret_cast<unsigned char *>(&rand_int);
|
s.start(true);
|
for (int i = 0; i < NUM_ITERATIONS; ++i) {
|
if (veryVerbose) { P(i) }
|
ASSERT(0 == Util::getRandomBytes(p1, sizeof rand_int));
|
}
|
s.stop();
|
double time = s.accumulatedUserTime() + s.accumulatedSystemTime() +
|
s.accumulatedWallTime();
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.