Code snippet for the cases when you can't understand how long application response visually.

Usage:
- call MeasureUtil.logNextFrameTime before you are expecting complex UI creation.
- you will see traces as result:

Timer::frames 140,156,172,172

which means that next frame starts rendering only after 140 ms. But average frame interval should be about 1000 / 31 = 32 ms. Second frame occurs after 156 ms after our method call.

Code is pretty simple, checking for time pass in ENTER_FRAME.

package {
 
    import flash.events.Event;
    import mx.core.Application;
 
    public class MeasureUtil {
 
        public static var startTime : Number = 0;
 
        public static var enabled : Boolean = true;
 
        private static var enterCounter : Number = 0;
 
        private static var enterCache : Array = [];
 
        private static var _startTime : int;
 
        private static var _stopTime : int;
 
        /**
         * Profiler function to monitor creation/update time for pages
         */
        public static function logNextFrameTime() : void {
            if (!enabled) {
                return;
            }
 
            if (enterCounter <= 0) {
                trace("Timer::on timer reset");
                startTime = new Date().getTime();
                Application.application.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            } else {
                trace("Timer::on timer continue");
                enterCounter += 4;
            }
            enterCounter = 4;
        }
 
        private static function onEnterFrame(event : Event) : void {
            enterCache.push((new Date().getTime() - MeasureUtil.startTime));
            enterCounter--;
            if (enterCounter <= 0) {
                Application.application.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
                trace("Timer::frames " + enterCache.join(","));
                enterCache = [];
            }
        }
 
        public static function start() : void {
            _startTime = new Date().getTime();
        }
 
        public static function stop(message : String) : void {
            _stopTime = new Date().getTime();
            trace("Timer::" + message + " " + (_stopTime - _startTime).toString());
        }
    }
}