SyncWait函数
刚在一网上看labwindowscvi教程时看见一函数讲解
SyncWait
void SyncWait(double begin_time,double interval)
不太明白参数begin_time是什么意思,根据字面意思是开始时间,但是开始时间怎么是double类型的?麻烦知道的朋友告诉下,谢谢
[解决办法]
参考下面:用double类型是因为32位int类型不够表示时间跨度从1970.1.1到比如2050.1.1经过的秒数。
difftime
Finds the difference between two times.
double difftime( time_t timer1, time_t timer0 );
Routine Required Header Compatibility
difftime <time.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
difftime returns the elapsed time in seconds, from timer0 to timer1. The value returned is a double-precision floating-point number.
Parameters
timer1
Ending time
timer0
Beginning time
Remarks
The difftime function computes the difference between the two supplied time values timer0 and timer1.
Example
/* DIFFTIME.C: This program calculates the amount of time
* needed to do a floating-point multiply 10 million times.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main( void )
{
time_t start, finish;
long loop;
double result, elapsed_time;
printf( "Multiplying 2 floating point numbers 10 million times...\n" );
time( &start );
for( loop = 0; loop < 10000000; loop++ )
result = 3.63 * 5.27;
time( &finish );
elapsed_time = difftime( finish, start );
printf( "\nProgram takes %6.0f seconds.\n", elapsed_time );
}
Output
Multiplying 2 floats 10 million times...
Program takes 2 seconds.
Floating-Point Support Routines
[解决办法]
Time Management Routines
See Also time