Jump to content

How to get faster then @SEC?


Recommended Posts

I was looking thru the date section and i couldnt find anything faster then @SEC (to get current time). Ive put a small piece of code together to see how fast i can read thru 100 lines, but since that is faster then 1 second i had to put 1000 lines instead.

But back to the question is there anyway to get the computer time on miliseconds?

Just posting the relevant code on the timer so you get the point :o

$a = 100
$oldtime = @sec
$checktime = 0
$currenttime = 0
While 1; Not StringInStr($test, "*** Chat Log Closed")
    
$currenttime = @sec
    If $currentline > $a Then
        $checktime = $currenttime - $oldtime
        $checktime = $checktime * 1000
        $a = $a + 100
        $oldtime = @sec
    EndIf
        
    $test = FileReadLine($file)
    GUICtrlSetData($prgProgress, 100 * ($CurrentLine / $TotalLines))
; Check how many lines are being read per second.
    $LinesPerSec = $CurrentLine / 1000
    
    ToolTip("At line: " & $CurrentLine & " Total Lines to read: " & $TotalLines & " Reading 100 lines @ " & $checktime & " ms",0,0)

Most of the code comes from smoke, wouter and neogia, that helped me alot earlier. Added a few things myself tho of course :geek:

<edit> Forgot to add now it barely shows 0 or 1000ms, change the lines to 1000 and remove the multiplier and seconds pop up. I could read 1000 lines @ 7 seconds. But id really like to figure out how to get miliseconds in an "exact" way. I noticed the TimerInit command, but it doesnt seem very reliable. </edit>

<edit> lol just noticed the topic i picked, i was meaning how to get more "precise" then a second, ie miliseconds ;) </edit>

Edited by huldu

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
Share on other sites

Added an estimated time aswell. But there is a problem when @sec i do $currenttime - $oldtime, can get erroneous. I thought my estimated time was off, but it was pretty much right on actually hehe. If i just could get miliseconds instead.. would be so much more easy, and more precise!.

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
Share on other sites

someone - (i believe holger?) posted a dllcall() to get more precise times w/in the past week.

Thank you found it! :o

While 1
    ToolTip(@Hour & ':' & @Min & ':' & @Sec & ':' & _MSec())
    Sleep(1)
WEnd

Exit

Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))

    $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    
    $stSystemTime = 0
    
    Return $sMilliSeconds
EndFunc

Thanks to holger for this.

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...