Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does the delphi ide increase the windows platform timer resolution?

I have noticed that my battery life is significantly worse on my laptop whenever I have the delphi 2010 ide open. When I powercfg /energy trace, it shows (among other things) that bds.exe has requested a smaller timer resolution than the default of 15.6ms.

Current Timer Resolution (100ns units) 10006 
Maximum Timer Period (100ns units) 156250 


Requested Period 10000 
Requesting Process ID 7996 
Requesting Process Path \Device\HarddiskVolume2\Program Files (x86)\Embarcadero\RAD Studio\7.0\bin\bds.exe 

Does delphi have a good reason to alter the platform timer resolution? Also do the latest versions of the ide have the same behavior?

like image 259
Joe Avatar asked Sep 01 '15 17:09

Joe


People also ask

What is platform timer resolution?

The default platform timer resolution is 15.6ms (15625000ns) and should be used whenever the system is idle. If the timer resolution is increased, processor power management technologies may not be effective. The timer resolution may be increased due to multimedia playback or graphical animations.

What is Windows timer resolution?

The standard windows timer has an interval of 10 to 25 miliseconds, timer resolution claims to be able to change that to 0.5 miliseconds.


1 Answers

The IDE uses a very old version of VirtualTrees.pas for the ProjectManager, StructureView and Log-Window. This version calls timeBeginPeriod in its InitializeGlobalStructures function and sets the timer resolution to the minimum (1). It is reset in the unit's finalization block.

VirtualTrees changed this behavior with this commit:

2013-09-20 21:40:21: No longer changing timer resolution globally (#365)

But the IDE still uses a very old version that isn't even using UnicodeString but WideString. So it wasn't updated since Delphi 2007.

like image 76
Andreas Hausladen Avatar answered Oct 21 '22 11:10

Andreas Hausladen