Desafíos de las pruebas de aplicaciones Web 2.0

Complemente las pruebas de rendimiento Web 2.0 usando métricas de rendimiento de representación de la GUI.

Volver al artículo

Apéndice A: Métodos de muestra para TransactionTimer Código escrito por Kenneth Thomson y Monica Luke
*Start a timing a transaction <p> * Call
with
<br><dd><code>TransactionTimer.startTimer();</code><br>
*/publicvoidstartTimer(){ Date today =newDate();sStartDate
=formatter.format(today); // there can be no more code after the timer starts
transactionStartTime = System.currentTimeMillis(); } /** * Stop timing a
transaction. Take a time snapshot and calculates the elapsed time.
<br> * After calling this method, the actual time value can be
retrieved using <code> getElapsedTime();<p> * * Call
with
<br><dd><code>TransactionTimer.stopTimer();</code><br>
* Value will be logged to the file as a number by default. *
*/publicvoidstopTimer(){stopTimer
(true);}/***@paramasNumbers<br>* Transaction timing
information can be written to file with labels to show seconds or
milliseconds.<br> * This approach makes the number values strings.
<br> * For cases where strings are useful, call <code>
stopTimer(false);</code> */publicvoidstopTimer
(booleanasNumbers){// first thing must be stop the timer
transactionStopTime = System.currentTimeMillis(); Date today
=newDate();sStopDate = formatter.format(today); // it's assumed all the math
should be done each time the timer is stopped. calculateTransactionTime(asNumbers);
PerformanceLogger.INSTANCE.writeResultToLog(this);}/** Calculate the
elapsed time between startTimer and stopTimer
*/privatevoidcalculateTransactionTime(){// calculate transaction
elapsed time transactionTime = transactionStopTime - transactionStartTime;
sElapsedTime=String.valueOf(transactionTime) ; }

Volver al artículo