载入中
自定义HTML载入中... loading
Win32 API:QueryPerformanceFrequency说明 [原创 2008-04-05 08:32:09]  删除... 
字体变小 字体变大

Win32 API:QueryPerformanceFrequency说明

The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists.

QueryPerformanceFrequency函数接收高精度计时器的频率,如果(硬件支持)有(高精度计时器).

BOOL QueryPerformanceFrequency(
  LARGE_INTEGER *lpFrequency   // address of current frequency(当前频率地址)
);
 

Parameters

参数

lpFrequency
Pointer to a variable that the function sets, in counts per second, to the current performance-counter frequency. If the installed hardware does not support a high-resolution performance counter, this parameter can be to zero.
指向函数设定的变量,以次数/秒计算当前高精度计时器的频率.如果所安装的硬件不支持高精度计时器,这个参数将为0.

Return Values

返回值

If the installed hardware supports a high-resolution performance counter, the return value is nonzero.

如果(所安装的)硬件支持高精度计时器,返回非0.

If the installed hardware does not support a high-resolution performance counter, the return value is zero.

如果(所安装的)硬件不支持高精度计时器,返回0. 

QuickInfo

快速信息

  Windows NT: Requires version 3.1 or later.需要3.1版本以上
  Windows: Requires Windows 95 or later.需要Win95以上
  Windows CE: Unsupported.不支持
  Header: Declared in winbase.h.在winbase.h中声明
  Import Library: Use kernel32.lib.使用kernel32.lib链接库

See Also

Timers Overview, Timer Functions, QueryPerformanceCounter

 以下为函数说明(摘自互联网上)

queryperformancecounter()这个函数返回高精确度性能计数器的值,它可以以微秒为单位计时.但是queryperformancecounter()确切的精确计时的最小单位是与系统有关的,所以,必须要查询系统以得到queryperformancecounter()返回的嘀哒声的频率.queryperformancefrequency()提供了这个频率值,返回每秒嘀哒声的个数.计算确切的时间是从第一次调用queryperformancecounter()开始的假设得到的large_integer   为nstartcounter,过一段时间后再次调用该函数结束的,设得到nstopcounter.两者之差除以queryperformancefrequency()的频率就是开始到结束之间的秒数.由于计时函数本身要耗费很少的时间,要减去一个很少的时间开销.但一般都把这个开销忽略.公式如下:  
                                nstopcounter-nstartcounter  
    elapsedtime=------------------------------------     -   overhead  
                                        frequency  
   
  double   time=(nstopcounter.quadpart-nstartcounter.quadpart)/frequency.quadpart.

分类: 编程基础
所属版块: 科技
票数:
什么是“我顶”?
点击数:    评论数:
本文章引用通告地址(TrackBack Ping URL)为:
本文章尚未被引用。
发表评论
大 名:
(不填写则显示为匿名者)
网 址:
(您的网址,可以不填)
标 题:
内 容:
请根据下图中的字符输入验证码:
(您的评论将有可能审核后才能发表)
和讯个人门户 v1.0 | 和讯部落 | 客服中心