1 # ifndef CPPAD_UTILITY_SPEED_TEST_HPP
2 # define CPPAD_UTILITY_SPEED_TEST_HPP
158 template <
class Vector>
160 void test(
size_t size,
size_t repeat),
161 const Vector& size_vec ,
165 CheckSimpleVector<size_t, Vector>();
167 size_t n = size_vec.size();
170 for(i = 0; i < n; i++)
171 {
size_t size = size_vec[i];
175 while( s1 - s0 < time_min )
176 { repeat = 2 * repeat;
181 double rate = .5 + double(repeat) / (s1 - s0);
183 rate_vec[i] =
static_cast<size_t>(
static_cast<float>(rate) );
354 while( pow10 <= value )
363 std::string Test(
size_t size,
size_t repeat),
388 inc != 0 && first != 0 && last != 0,
389 "inc, first, or last is zero in call to SpeedTest"
392 (inc > 0 && first <= last) || (inc < 0 && first >= last),
393 "SpeedTest: increment is positive and first > last or "
394 "increment is negative and first < last"
398 maxSize = size = first;
399 while( (inc > 0 && size <= last) || (inc < 0 && size >= last) )
405 if( ((
int) size) + inc > 0 )
412 while( (inc > 0 && size <= last) || (inc < 0 && size >= last) )
417 while( s1 - s0 < 1. )
418 { repeat = 2 * repeat;
420 name = Test(size, repeat);
423 double r = .5 + double(repeat) / (s1 - s0);
425 rate =
static_cast<size_t>(
static_cast<float>( r ) );
427 if( size == first && name !=
"" )
428 cout << name << endl;
433 std::cout <<
"size = " << int(size);
436 while( ndigit < maxSizeDigit )
448 digit = rate / pow10;
451 std::cout << int(digit);
456 if( (ndigit > 0) && (ndigit % 3 == 0) )
462 if( ((
int) size) + inc > 0 )
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Vector speed_test(void test(size_t size, size_t repeat), const Vector &size_vec, double time_min)
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
Function that returns the elapsed seconds from first call.
void SpeedTest(std::string Test(size_t size, size_t repeat), size_t first, int inc, size_t last)
void SpeedTestNdigit(size_t value, size_t &ndigit, size_t &pow10)
double elapsed_seconds(void)
Returns the elapsed number since the first call to this function.