MCPcopy Create free account
hub / github.com/coin-or/CppAD / Test

Function Test

speed/example/speed_program.cpp:21–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19double global_result = 0.0;
20
21std::string Test(size_t size, size_t repeat)
22{ // setup
23 double *a = new double[size];
24 double *b = new double[size];
25 size_t i = size;;
26 while(i)
27 { --i;
28 a[i] = double(i);
29 b[i] = double(2 * i);
30 }
31 // operations we are timing
32 while(repeat--)
33 { i = size;;
34 while(i)
35 { --i;
36 global_result += a[i] * b[i];
37 }
38 }
39 // teardown
40 delete [] a;
41 delete [] b;
42
43 // return a test name that is valid for all sizes and repeats
44 return "double: result = sum_i a[i] * b[i]";
45}
46int main(void)
47{
48 CppAD::SpeedTest(Test, 20, 20, 100);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected