Jump to content
• Sign Up

# Timer Question - RESOLVED

## Recommended Posts

Hi

This is going to be a stupid question but I hope someone can help.

I have a timer in my script which logs the time in seconds it took for the script to complete. In the middle of my script i use a sleep command of 5 seconds. I would like to subtract the 5 seconds from the total time before I write the final results. Any ideas would be appreciated.

Here is my existing code:

$timer=TimerInit() I DO SOME STUFF HERE sleep(5000) <------ I want to subtract this 5 seconds from the timer before I wright the results to the text file$handle = Fileopen("c:\logs\times.txt",1)         ; Open the target file
FileWriteline($handle,Round(TimerDiff($timer)/1000,1))              ; Append text to the target file
FileClose($handle) ; Close target file Edited by Kasteel #### Share this post ##### Link to post ##### Share on other sites Does this do it for you? FileWriteline($handle,Round((TimerDiff($timer)- 5000)/1000,1)) OR FileWriteline($handle,Round(TimerDiff($timer)/1000 -5,1)) Edited by czardas #### Share this post ##### Link to post ##### Share on other sites Does this do it for you? FileWriteline($handle,Round((TimerDiff(\$timer)- 5000)/1000,1)

Thanks for your help

#### Share this post

##### Share on other sites

I often get it wrong, so I needed to check it. Just added an alternative to the above post. I miscounted the brackets, but it's now correct.

Edited by czardas

## 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

• ### Recently Browsing   0 members

No registered users viewing this page.

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...