Jump to content
Sign in to follow this  
Bowmore

TimerDif() and RunWait() - Limits

Recommended Posts

Bowmore

I am running some processes from a Autoit GUI by calling another autoit application using RunWait() and passing it data via command line parameters. The called application can take between less than 1 second to over a day to return depending on the parameters I pass it.

The GUI application displays a timer shown how long it has been waiting for the called application to complete its task. The issue I have is that occasionally I have had a Windows General Protection Fault in GUI application when the called application takes a very long time to complete its task, although the called application has always continued running and successfully completed its task.

A couple of questions to help me track down what is causing the GPF.

1) Does anyone know what the maximum valid time difference TimerDiff() will return?

2) Is there a maximum time that RunWait() will wait for?

I haven't supplied a script to demonstrate the issue as doubt that anyone would to run a script for a day or more just to see when it crashed. I will be running a few of my own experiments over the weekend to see if I can track down the cause.

Running Beta 3.2.9.10


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

Share this post


Link to post
Share on other sites
weaponx

I'm not sure what format TimerInit() returns, I know the value is in milliseconds. I thought it might be the number of milliseconds since the Unix Epoch but it doesn't return the right value.

$milliseconds = TimerDiff(0)
$secs = $milliseconds / 1000
$mins = $secs / 60
$hours = $mins / 60
$days = $hours / 24
$years = $days / 365

;Should be about almost 38 years??? Actually returns .0086
MsgBox(0,"",$years)

Share this post


Link to post
Share on other sites
PsaltyDS

I'm not sure what format TimerInit() returns, I know the value is in milliseconds. I thought it might be the number of milliseconds since the Unix Epoch but it doesn't return the right value.

$milliseconds = TimerDiff(0)
$secs = $milliseconds / 1000
$mins = $secs / 60
$hours = $mins / 60
$days = $hours / 24
$years = $days / 365

;Should be about almost 38 years??? Actually returns .0086
MsgBox(0,"",$years)
Ticks since last reboot, maybe?

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Bowmore

Ticks since last reboot, maybe?

:P

I think you may well be correct

Calling TimerInit() twice with Sleep(10000) between gives

$t1 = 59782825523736

$t2 = 59801445711749

Looking on http://msdn2.microsoft.com/en-us/library/ms644904.aspx for QueryPerformanceCounter() which I believe TimerInit() and TimerDiff() are based on it states that the result is returned counts. This I assume is the number of CPU clock cycles since the last reboot so the actual value will be dependent on the speed of the CPU.

Edit due to premature post

Edited by Bowmore

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

Share this post


Link to post
Share on other sites
weaponx

It looks like PsaltyDS is right.

I compared my results from this code to the Uptime in Everest Ultimate Edition and they match:

$milliseconds = TimerDiff(0)
$years = Int($milliseconds / 31536000000)
$remainMS = Mod($milliseconds, 31536000000)
$days = Int($remainMS / 86400000)
$remainMS = Mod($milliseconds, 86400000)
$hours = Int($remainMS / 3600000)
$remainMS = Mod($milliseconds, 3600000)
$minutes = Int($remainMS / 60000)
$remainMS = Mod($milliseconds, 60000)
$seconds = Int($remainMS / 1000)
$remainMS = Mod($milliseconds, 1000)

MsgBox(0,"Time since last boot","Years: " & $years & @CRLF & "Days: " & $days & @CRLF & "Hours: " & $hours & @CRLF & "Minutes: " & $minutes & @CRLF & "Seconds: " & $seconds & @CRLF & "Milliseconds: " & Int($remainMS))

EDIT: I know this doesn't really help your problem but I was trying to see how large the result of TimerDiff() could be. I don't know how AutoIT handles numbers in the trillions.

Edited by weaponx

Share this post


Link to post
Share on other sites
Valuater

Maybe....

#include <File.au3>


$argument = "data passed"

$program = "Program exe "


$Log = @ScriptDir & "\Log_Files\" & @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @SEC & ".log"

_FileWriteLog( $Log, "*** TASK START ***")

_FileWriteLog( $Log, "Argument = " & $argument)

$ret = RunWait( $program & $argument)

_FileWriteLog( $Log, "return = " & $ret)

_FileWriteLog( $Log, "*** END TASK ***" & @CRLF & @CRLF)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Bowmore

I am running some processes from a Autoit GUI by calling another autoit application using RunWait() and passing it data via command line parameters. The called application can take between less than 1 second to over a day to return depending on the parameters I pass it.

The GUI application displays a timer shown how long it has been waiting for the called application to complete its task. The issue I have is that occasionally I have had a Windows General Protection Fault in GUI application when the called application takes a very long time to complete its task, although the called application has always continued running and successfully completed its task.

A couple of questions to help me track down what is causing the GPF.

1) Does anyone know what the maximum valid time difference TimerDiff() will return?

2) Is there a maximum time that RunWait() will wait for?

I haven't supplied a script to demonstrate the issue as doubt that anyone would to run a script for a day or more just to see when it crashed. I will be running a few of my own experiments over the weekend to see if I can track down the cause.

Running Beta 3.2.9.10

Thanks for all your contibutions.

I've just finished a 48 hour run of my script on two PCs at home. It was another users PC at work that gave me the problem it had worked OK om the PC I developed it on.

The script ran perfectly for 48 hours on 2 different PCs so I think I can rule out my suspicions that there may be an issue with one of these function TimerDiff(), RunWait() or AdlibEnable() when used in a script that runs for a long time. I can only concluded that the cause is with that one PC at work, Possibly a conflict with some other application running on that PC or the person using it. :P

I normally enjoy the challenge involved with debugging an application but when it takes more that a days running before the problem occurs it's a real pain in the ass. ;)

Thanks again for your suggestions


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

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  

×