Chapter 12: Utilities

ctime

Returns the number of CPU seconds used.

Synopsis

#include <imsl.h>

double imsl_ctime ( )

Return Value

The number of CPU seconds used so far by the program.

Example

The CPU time needed to compute

is obtained and printed. The time needed is, of course, machine dependent. The CPU time needed will also vary slightly from run to run on the same machine.

 

#include <imsl.h>

main()
{
    int     k;
    double  sum, time;
                                /* Sum 1 million values */
    for (sum=0, k=1;  k<=1000000; k++)
         sum += k;
                                /* Get amount of CPU time used */
    time = imsl_ctime();
    printf("sum = %f\n", sum);
    printf("time = %f\n", time);
}

Output

sum = 500000500000.000000
time = 2.260000


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260