1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| package com.inm.framework.utils
{
import flash.utils.*;
/** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ****
* Debug class
*/
public class Debug
{
static private const __debugEnabled:Boolean = true;
static private var timers:Array = new Array();
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
//* HOW TO USE THE CHRONOMETER
//*
//* // ALLOCATE A CHRONO HANDLE
//* var chrono:int = Debug.startChrono();
//*
//* // DO SOMETHING ...
//*
//* // STOP THE CHRONO AND DISPLAY A MESSAGE
//* Debug.stopChrono("methodName", chrono);
//*
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
/** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
* startChrono Method
*/
static public function startChrono():int
{
var begin:Number = flash.utils.getTimer();
if (__debugEnabled)
{
timers[timers.length] = begin;
return timers.length-1;
}
return -1;
}
/** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
* stopChrono Method
*/
static public function stopChrono(functionName:String, chronoID:int):void
{
var end:Number = flash.utils.getTimer();
if (__debugEnabled)
{
trace(functionName, "took " +
String(end-timers[chronoID])+ " ms");
}
}
} // class
} // package |
Partager