Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transactions Vs Built-In Timers in QTP

Status
Not open for further replies.

anarchistx

Programmer
Feb 21, 2005
4
US
Hello everybody,

I would like to know which is better to use, transactions or built-in timers like Seconds in QTP?

I am trying to measure the execution time of a webmail app when a user clicks on FROM. It'll organize all the emails and sort them.

I've used transactions and it came out to 6.3 seconds. I used the timer Seconds, and it came out to 6 seconds. My question is which is the standard method for measuring response time?

Thanks a lot
 
I suppose it depends on your need for accuracy. IIRC, Seconds in QTP rounds to the nearest second.

From the Help page on Timers:
ATP Help said:
Timer Property
Description
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.

Remarks
The Timer property is the default property for the MercuryTimers collection object.

Syntax
Set MyTimer = MercuryTimers.Timer(TimerName)


Argument
Type
Description

TimerName String The name of the specific timer.


Notes:

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.

Example
The following example uses two MercuryTimer objects (Timer1 and Timer2) to measure elapsed time in milliseconds, send a report to the test 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 micInfo, "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

Let me know if you need further help on this

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top