Prev Next Index-> contents reference index search external Up-> CppAD utility speed_test CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix utility-> ErrorHandler NearEqual speed_test SpeedTest time_test test_boolofvoid NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort to_string set_union sparse_rc sparse_rcv speed_test-> speed_test.cpp Headings-> Syntax Purpose Motivation Include Vector test ---..size ---..repeat size_vec time_min rate_vec Timing Example

Run One Speed Test and Return Results

Syntax
# include <cppad/utility/speed_test.hpp>  rate_vec = speed_test(test, size_vec, time_min)

Purpose
The speed_test function executes a speed test for various sized problems and reports the rate of execution.

Motivation
It is important to separate small calculation units and test them individually. This way individual changes can be tested in the context of the routine that they are in. On many machines, accurate timing of a very short execution sequences is not possible. In addition, there may be set up and tear down time for a test that we do not really want included in the timing. For this reason speed_test automatically determines how many times to repeat the section of the test that we wish to time.

Include
The file cppad/speed_test.hpp defines the speed_test function. This file is included by cppad/cppad.hpp and it can also be included separately with out the rest of the CppAD routines.

Vector
We use Vector to denote a simple vector class with elements of type size_t.

test
The speed_test argument test is a function with the syntax       test(size, repeat)  and its return value is void.

size
The test argument size has prototype       size_t size  It specifies the size for this test.

repeat
The test argument repeat has prototype       size_t repeat  It specifies the number of times to repeat the test.

size_vec
The speed_test argument size_vec has prototype       const Vector& size_vec  This vector determines the size for each of the tests problems.

time_min
The argument time_min has prototype       double time_min  It specifies the minimum amount of time in seconds that the test routine should take. The repeat argument to test is increased until this amount of execution time is reached.

rate_vec
The return value rate_vec has prototype       Vector& rate_vec  We use $n$ to denote its size which is the same as the vector size_vec . For $i = 0 , \ldots , n-1$,       rate_vec[i]  is the ratio of repeat divided by time in seconds for the problem with size size_vec[i] .

Timing
If your system supports the unix gettimeofday function, it will be used to measure time. Otherwise, time is measured by the difference in  (double) clock() / (double) CLOCKS_PER_SEC  in the context of the standard <ctime> definitions.

Example
The routine speed_test.cpp is an example and test of speed_test.