Sign in to follow this  
Followers 0
kaesereibe

QueryPerformance

5 posts in this topic

#1 ·  Posted (edited)

QueryPerformance

This example shows just a way to calculate the TimeDiff. Otherwise please use the TimerDiff() function.

- MSDN System Information Functions: Kernel32.dll QueryPerformanceCounter

- MSDN System Information Functions: Kernel32.dll QueryPerformanceFrequency

Func QueryPerformance($N = 0)
    Static $F, $A, $Q, $P, $X
    Local $R
    If $N And Not $P Then
        $F = DllCall("Kernel32.dll", "Int", "QueryPerformanceFrequency", "Int64*", "")
        $F = $F[1]
        $P = DllCall("Kernel32.dll", "Int", "QueryPerformanceCounter", "Int64*", "")
        $P = $P[1]
        Return $F + $P + ($X = 0) + ($A = 0)
    EndIf
    $Q = DllCall("Kernel32.dll", "Int", "QueryPerformanceCounter", "Int64*", "")
    $A = $A + $Q[1] - $P
    $P = $Q[1]
    $X = $X + 1
    $R = $A / $X / $F
    Return ($N And $X = $N) ? BitShift($X = $X - 1, -64) : ($N = 0 And $R) ? ($R + ($A = 0) + ($P = 0) + ($X = 0)) : 1
EndFunc    ;==> QueryPerformance() AutoIt v3.3.12.0
Edited by kaesereibe

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Examples:

QueryPerformance(1)
Sleep(2500)
$End = QueryPerformance(0)
MsgBox(0, "QueryPerformance()", $End)



$i = 0
QueryPerformance(1)
While $i <> 10000000
    $i += 1
WEnd
$End = QueryPerformance(0)
MsgBox(0, "QueryPerformance()", $End)
Edited by kaesereibe

Share this post


Link to post
Share on other sites

This is just the same like this:

#include <Timers.au3>
Global $Start = _Timer_Init()
Sleep(200)
ConsoleWrite (_Timer_Diff($Start) & @LF)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Like I said in my top post:

"This example shows just a way to calculate the TimeDiff. Otherwise please use the TimerDiff() function."

Its the same in short and only 1 function

QueryPerformance(1) start

QueryPerformance(0) to get the diff & reset

Edited by kaesereibe

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

And

Global $Start = _Timer_Init() ;to start

ConsoleWrite (_Timer_Diff($Start) & @LF) ;to get the diff

@kaesereibe that is unnecessarily complicated, all to replace a native function that works.

But i do appreciate the effort to come up with something new. Keep it up. :)

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0