# Include <stdio. h>
# Include <stdlib. h>
// # Include <sys/types. h>
# Include <unistd. h>
# Include <time. h>
# Include <sys/time. h>
Int main (INT argc, char * argv [])
{
Struct timeval t_startrun, t_endrun;
Int flag = 0;
Char timef [100];
Time_t T;
Struct TM * today;
For (INT I = 0; I <1000; I ++)
{
Gettimeofday (& t_startrun, 0 );
Usleep (1000000 );
Gettimeofday (& t_endrun, 0 );
// Printf ("the program's running time is % ld ms! ", 100 );
// Printf ("the program's running time is MS! ");
// (T_endrun. TV _sec-t_startrun. TV _sec) x 100000 + t_endrun. TV _usec-t_startrun. TV _usec)/1000 );
Long ltime = (t_endrun. TV _sec-t_startrun. TV _sec) * 1000000 + t_endrun. TV _usec-t_startrun. TV _usec)/1000;
If (ltime <0)
{
Printf ("t_endrun. TV _sec = % d-t_startrun. TV _sec = % d ,"
"T_endrun. TV _usec = % d-t_startrun. TV _usec = % d/R/N ",
T_endrun. TV _sec, t_startrun. TV _sec,
T_endrun. TV _usec, t_startrun. TV _usec );
}
T = t_endrun. TV _sec;
Today = localtime (& T );
Strftime (timef, 100, "% Y-% m-% d % H: % m: % s", today );
Printf ("% d-% d, % d, % S/R/N", t_endrun. TV _sec, t_endrun. TV _usec, T, timef );
Printf ("the program's running time is % ld ms! /R/N ", ltime );
Fflush (stdout );
}
Return 0;
}