difftime

Description

Finds the difference between two times.

#include <time.h> Required only for function declarations  

double difftime( time_t timer1, time_t timer0 );

timer0 Beginning time  
timer1 Ending time  

Remarks

The difftime function computes the difference between the supplied time values, timer0 and timer1.

Return Value

The difftime function returns, in seconds, the elapsed time from timer0 to timer1. The value returned is a double-precision number.

Compatibility

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

time

Example

/* DIFFTIME.C: This program calculates the amount of time needed to

* do a floating-point multiply 50000 times.

*/

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

void main( void )

{

time_t start, finish;

unsigned loop;

double result, elapsed_time;

printf( "This program will do a floating point multiply 50000 times\n" );

printf( "Working...\n" );

time( &start );

for( loop = 0; loop < 50000L; loop++ )

result = 3.63 * 5.27;

time( &finish );

elapsed_time = difftime( finish, start );

printf( "\nProgram takes %6.2f seconds.\n", elapsed_time );

}

Output

This program will do a floating point multiply 50000 times

Working...

Program takes 4.00 seconds.