MercuryTimers Object (Collection)
Description
A collection of MercuryTimer objects that measure time in milliseconds.
IMPORTANT
You can use the MercuryTimers collection object to measure elapsed time. The MercuryTimers collection object has a single default property, Timer, which returns a MercuryTimer object.
Properties
Timer | Accesses the timer with the specified name from the MercuryTimers collection object, or creates a new timer with this name if the timer does not yet exist. |
Timer Property
Accesses the timer with the specified name from the MercuryTimers collection object, or creates a new timer with this name if the timer does not yet exist.
Description
Set MyTimer = MercuryTimers.Timer(TimerName)
Argument | Type | Description |
---|---|---|
TimerName | String | The name of the specific timer. |
Note:
You can omit the word Timer
in the syntax, because Timer
is the default property for the MercuryTimers collection object.
Instead of returning the internal timer object to the MyTimer variable, you can perform MercuryTimer methods directly on the returned object within the same statement, as shown in the following example.
Return Value
A Variant value. A MercuryTimer object.
IMPORTANT
The Timer property is the default property for the MercuryTimers collection object.
The following example uses two MercuryTimer objects (Timer1
and Timer2
) to measure elapsed time in milliseconds, send a report to the run results, convert the time from milliseconds to seconds, and set a transaction.
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Wait 1
MercuryTimers("Timer1").Stop 'After one second, stop Timer1.
MercuryTimers("Timer2").Start 'Start measuring time usingTimer2.
'Two seconds later, restart Timer1 (which will continue to measure time from
'the time it stopped while Timer2 continues uninterrupted).
Wait 2
MercuryTimers("Timer1").Continue
'Three seconds later, stop both timers and send a report to the test results specifying the elapsed time for each of the timer objects
'(Timer1 ~4000 ms; Timer2 ~5000 ms).
Wait 3
Reporter.ReportEvent micDone, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1").Stop() & "ms, Timer2: " & MercuryTimers("Timer2").Stop() & "ms"
'Set a transaction manually for each of the timer objects. Convert the elapsed time for each of the timer objects from milliseconds to seconds so
'the elapsed time will be reported correctly in the transaction.
Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass
Services.SetTransaction "Timer2",MercuryTimers("Timer2").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