Chapter 15: Utilities

ctime

Returns the number of CPU seconds used.

Synopsis

#include <imsls.h>

double imsls_ctime ()

Return Value

The number of CPU seconds used by the program.

Example

The CPU time needed to compute

is obtained and printed. The time needed is machine dependent. The CPU time needed will varies slightly from run to run on the same machine.

#include <imsls.h>

 

int 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 = imsls_ctime();

    printf("sum = %f\n", sum);

 

    printf("time = %f\n", time);

}

Output

sum = 500000500000.000000

time = 0.820000


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