OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: -QueryPerformanceCounter
View page
Source of version: 4
(current)
{TRANSCLUDE(page="todoBox")} * add useful forum links (e.g. with code snippets) {TRANSCLUDE} {INCLUDE(page="ogrelex ext tpl")/} --- The __QueryPerformanceCounter__ is the most precise time stamp counter on Windows systems. It's useful e.g. for ((-FPS|FPS)) calculations. !!!Notes: * The value of __QueryPerformanceFrequency__ never changes, while a system is running. * __Aware:__ It's possible that __QueryPerformanceFrequency__ returns 0 on some hardware systems. * __Aware:__ The difference between an older and a newer value of the __QueryPerformanceCounter__ can be negative. (This can happen when the thread moves from one CPU core to an other.) !!!Forum quotes: {QUOTE(replyto="mstoyke (2010)")}Using the QueryPerformanceCounter functions can cause problems on multi-core CPUs, at least there were some serious problems in the past. I don't know if the .NET Stopwatch class is aware of the problem and contains a fix. On most machines you should be fine using any of these methods. If you have strange effects, just remember that you might have to take care of these bugs. A little more detail: On multi-core CPUs the performance counter on different cores can have different values. If the scheduler changes your program flow to another core, you might get strange readings like large differences between calls. If you create a time delta every frame (currentTimeStamp - lastTimeStamp) and you get negative values, you just encountered this problem. The easiest way is to use a background thread with an affinity mask that binds it to only one core. So the functions will always use the same performance counter and the problem is solved. You'll have to do this in C or C++ code, because .NET has its own internal scheduler that is independent of the system scheduler and you can't change the affinity mask in a reliable way.{QUOTE} !!See also: * [http://msdn.microsoft.com/en-us/library/ee417693%28VS.85%29.aspx|Game Timing and Multicore Processors] - important notes * [http://msdn.microsoft.com/en-us/library/ms644904(v=VS.85).aspx|QueryPerformanceCounter] - AP description * [http://msdn.microsoft.com/en-us/library/ms644905%28VS.85%29.aspx|QueryPerformanceFrequency] - API description * [http://en.wikipedia.org/wiki/Time_Stamp_Counter|Time Stamp Counter] - Wikipedia * [http://support.microsoft.com/kb/172338|How To Use QueryPerformanceCounter to Time Code] - MSDN page with code snippets * [http://support.microsoft.com/kb/274323|Performance counter value may unexpectedly leap forward] - MSDN * [http://en.wikipedia.org/wiki/High_Precision_Event_Timer|High Precision Event Timer] (HPET) - Wikipedia, formerly ''Multimedia Timer'' * [http://www.microsoft.com/whdc/system/sysinternals/mm-timer.mspx|Guidelines For Providing Multimedia Timer Support] - MSDN, about timers * [http://support.microsoft.com/kb/306979|How to use the QueryPerformanceCounter in Visual C#] - MSDN; Code snippet for use ((MOGRE|Mogre))
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
14 online users