MercuryTimer Object
An internal timer object that measures the passage of time in milliseconds.
IMPORTANT
The MercuryTimer object is an internal timer item of the MercuryTimers collection object.
Methods and Properties
Continue | Continues running the timer from the time it stopped (without resetting it). |
Reset | Returns the elapsed time in milliseconds and resets the timer to zero. |
Start | Starts the timer. |
Stop | Stops the timer, if it is running, and returns the elapsed time in milliseconds. |
ElapsedTime | Returns the total accumulated time in milliseconds since the timer started. |
Continue Method
Description
Continues running the timer from the time it stopped (without resetting it).
If the timer is already running, the Continue method does not affect it.
Syntax
MercuryTimers.Timer(TimerName).Continue
or
MercuryTimers(TimerName).Continue
Note: You can omit the Timer property in the syntax, because Timer is the default property for the MercuryTimers collection object.
IMPORTANT
If the timer is already running, the Continue method does not affect it.
The following example continues the stopped MercuryTimer object, Timer1, from the time it stopped.
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Wait 1
MercuryTimers("Timer1").Stop 'After one second, stop Timer1.
'Two seconds later, restart Timer1 (which will continue to measure time from
'the time it stopped).
Wait 2
MercuryTimers("Timer1").Continue
Reset Method
Description
Returns the elapsed time in milliseconds and resets the timer to zero.
If the timer is already running, the Reset method stops it before resetting the time to zero.
Syntax
retTime=MercuryTimers.Timer(TimerName).Reset
or
retTime=MercuryTimers(TimerName).Reset
Note: You can omit the Timer
property in the syntax, because Timer
is the default property for the MercuryTimers collection object.
Return Value
A Number. The elapsed time in milliseconds.
IMPORTANT
If the timer is already running, the Reset method stops it before resetting the time to zero.
The following example resets the stopped MercuryTimer object, Timer1
.
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Wait 1
MercuryTimers("Timer1").Stop 'After one second, stop Timer1.
'Two seconds later, reset Timer1 so it will start to measure time from zero
Wait 2
MercuryTimers("Timer1").Reset
Start Method
Description
Starts the timer. If the timer is already running, resets the timer and starts counting from zero.
Syntax
MercuryTimers.Timer(TimerName).Start
or
MercuryTimers(TimerName).Start
Note: You can omit the Timer
property in the syntax, because Timer
is the default property for the MercuryTimers collection object.
The following example creates and starts the MercuryTimer object named Timer1, or, if Timer1 already exists, this example restarts it.
MercuryTimers("Timer1").Start
Wait 2
MercuryTimers("Timer1").Stop
Stop Method
Description
Stops the timer, if it is running, and returns the elapsed time in milliseconds.
Syntax
MercuryTimers.Timer(TimerName).Stop
or
MercuryTimers(TimerName).Stop
Note: You can omit the Timer
property in the syntax, because Timer
is the default property for the MercuryTimers collection object.
Return Value
A Number. The total time in milliseconds since the timer started.
IMPORTANT
If the timer is already stopped, the Stop method returns the time in milliseconds.
You can use the Continue method to restart the timer and continue counting from where the timer stopped. (This does not reset the timer.)
The following example stops the MercuryTimer object named Timer1, two seconds after it starts measuring time.
MercuryTimers("Timer1").Start
Wait 2
MercuryTimers("Timer1").Stop
ElapsedTime Property
Description
Returns the total accumulated time in milliseconds since the timer started.
Syntax
retTime = MercuryTimers.Timer(TimerName).ElapsedTime
or
retTime = MercuryTimers(TimerName).ElapsedTime
or
retTime = MercuryTimers.Timer(TimerName)
or
retTime = MercuryTimers(TimerName)
Note: You can omit the Timer
property and/or ElapsedTime
property in the syntax, because Timer
is the default property for the MercuryTimers collection object, and ElapsedTime
is the default property of the MercuryTimer object.
Return Value
A Number. The total accumulated time in milliseconds since the timer started.
IMPORTANT
The ElapsedTime property is the default property for the MercuryTimer object.
The following example returns the elapsed time in milliseconds for the MercuryTimer object named Timer1. It then sends a report to the run results, convert the time from milliseconds to seconds, and sets a transaction.
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
'Three seconds later, stop Timer1 and send a report to the test
'results specifying the elapsed time in milliseconds (~3000 ms).
Wait 3
Reporter.ReportEvent micDone, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1").Stop() & "ms"
'Set a transaction manually and convert the elapsed time from milliseconds to
'seconds so the elapsed time will be reported correctly in the transaction.
Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object