GetTickCount64
GetTickCount64
GetTickCount64()函数返回系统启动后经过的毫秒数。
ulong GetTickCount64();返回值
一个ulong类型值。
注意
计数器仅限于系统计时器的精度,通常以10-16毫秒精度返回结果。与GetTickCount不同,它是uint类型,其内容在计算机连续运行的情况下,每49.7天超限一次,而GetTickCount64()可用于无限的计算机操作时间且不会超限。
示例:
#define MAX_SIZE 40
//+------------------------------------------------------------------+
//| 用于测量计算40个Fibo数的时间的脚本 |
//+------------------------------------------------------------------+
void OnStart()
{
long fib_array[MAX_SIZE];
//--- 存储初始值
ulong start=GetTickCount64();
//--- 一个循环,在这个循环中,我们从Fibo序列中计算出给定数量的数字
for(int i=0;i<MAX_SIZE;i++)
fib_array[i]=TestFibo(i);
//--- 以毫秒为单位获取花费的时间
ulong time=GetTickCount64()-start;
//--- 在EA日志中显示错误信息
ArrayPrint(fib_array);
PrintFormat("Calculating the first %d Fibonacci numbers took %I64u ms",MAX_SIZE,time);
}
//+------------------------------------------------------------------+
//| 通过序列号获取Fibo号码的函数 |
//+------------------------------------------------------------------+
long TestFibo(long n)
{
//--- 斐波序列的第一个成员
if(n<2)
return(1);
//--- 所有后续成员都使用该方程式计算
return(TestFibo(n-2)+TestFibo(n-1));
}另见
日期和时间、EventSetMillisecondTimer、 GetTickCount、GetMicrosecondCount