Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

QueryPerformanceCounter Function


  • Please log in to reply
6 replies to this topic
Foom as Guest
  • Guests
  • Last active:
  • Joined: --
Nothing really big but it worked so nice that i had to share it :).

What it does?
Returns the seconds elapsed since the last call to itself with a microsecond resolution.

Example?
#SingleInstance Force 
#NoEnv 
SetBatchLines -1  ; always set this if you do performance tests.

LastTickCount=%A_TickCount% ;just to see the difference 
QPC() 
sleep, 1337  ; 1.337 seconds 
msgbox, % "Tick method = " A_TickCount-LastTickCount "`nQPC() method = " QPC() 

QPC() 
{ 
    Static QPCLAST, QPCNOW, QPCFREQ 

    if not QPCFREQ 
        if not DllCall("QueryPerformanceFrequency", "Int64 *", QPCFREQ) 
            return "Fail QPF" 

    QPCLAST=%QPCNOW% 
    if not DllCall("QueryPerformanceCounter", "Int64 *", QPCNOW) 
        return "Fail QPC" 

    return (QPCNOW-QPCLAST)/QPCFREQ 
}


  • Guests
  • Last active:
  • Joined: --
Hum.
Every time i post in the "Scripts And Functions Forum" i post as guest, thought i am logged in as foom

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Cool, I have my own benchmark script too...

qpc("Sleep, 1")
MsgBox, % qpc() ; (131) #1=2.043837

; 2.043837/131*1000=15.6018

Yours:

QPC()
Sleep, 1
MsgBox, % QPC() ; 0.017669

; 0.017669*1000=17.669

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


  • Guests
  • Last active:
  • Joined: --
; 2.043837/131*1000=15.6018
I don't understand this. Whats the 131 for?

BTW. This probably gets posted by Guest again. But its me foom. Could a moderator please tell me whats going on? I can post in the "Ask For Help Forum" just fine but in this forum it allways posts as Guest. This came out of nowhere. Therefore i ask: "Have there any changes been made to the forum software which could cause this problem?".

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006
Test...
Edit: Strange i changed the expiry-date of some cookies for this site from 1970-01-01 to 2008-01-01 and could post this as logged in user.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

; 2.043837/131*1000=15.6018
I don't understand this. Whats the 131 for?

The 131 value is the number of iterations my algorithm calculated for a reliable result. Read the discussion between Laszlo and myself in the linked topic for more info.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Nice and simple to use! (You don't need QPCLAST to be static, but it might speed things up a bit.)