Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
System Information
 QueryPerformanceFrequency function
QueryPerformanceFrequency function

Retrieves the frequency of the high-resolution performance counter, if one exists. The frequency cannot change while the system is running.

Syntax

BOOL WINAPI QueryPerformanceFrequency(
  __out  LARGE_INTEGER *lpFrequency
);

Parameters

lpFrequency [out]

Type: LARGE_INTEGER*

A pointer to a variable that receives the current performance-counter frequency, in counts per second. If the installed hardware does not support a high-resolution performance counter, this parameter can be zero.

Return value

Type: BOOL

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

If the function fails, the return value is zero. To get extended error information, call GetLastError. For example, if the installed hardware does not support a high-resolution performance counter, the function fails.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

Reference
QueryPerformanceCounter
Conceptual
Timers

 

 

Send comments about this topic to Microsoft

Build date: 9/7/2011

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
This function is not for obtain CPU frequency      Heeroyui1777   |   Edit   |   Show History
This function NOT obtain the CPU frequency (or CPU speed). This function is to get the frequency of the high resolution timer counter. Timer counter value is obtained with QueryPerformanceTimer()
Tags What's this?: Add a tag
Flag as ContentBug
"Frequency"      Xelous ... Thomas Lee   |   Edit   |   Show History
Technically this article, and the community comments are correct, this function does query the frequency of the CPU. but only in so far as that 99.9% of current CPU's available operate at the same frequency as the Performance timer component within. However, you must remember you are querying for the frequency of this timer, not the frequency of the actual CPU.

I myself (on an Intel Celeron Mobile based machine) have noted on occasion that the CPU frequency reported in tools such as CPU-Z is different to the frequency reported by this function call. This is especially true when using Intel Speed Step, or when the BIOS has been set to use CPUTHRM settings to throttle down the CPU when overheating.

In these latter occasions is common to see a higher return from "QueryPerformanceFrequency" than one can see reported by the CPU. Skewing any timing performed in a high performance loop.
Tags What's this?: Add a tag
Flag as ContentBug
retrieve CPU speed      arabcoder ... Thomas Lee   |   Edit   |   Show History
Apparently this function can be used to retrieve the processor speed,is it correct ?

arabcoder
Tags What's this?: Add a tag
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool QueryPerformanceFrequency(out long lpFrequency);
Tags What's this?: Add a tag
Flag as ContentBug
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function QueryPerformanceFrequency(<Out> ByRef lpFrequency As Long) As Boolean
End Function
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker