Is there a way to find out how long a function takes?

I have a function that I want, but I do not know how to do it. In javascript, I can just get the current time in milliseconds, run the rest of my function, get the current time in milliseconds again and warn the difference. Viola, I know how long the function took.

In ActionScript, it runs all at once, so my start and end times are the same. How to measure the amount of time that a function performs for processing?

Thank,

+3
source share
1 answer

. , . toMeasure 100 time1 time2 100. . , .

            private var time1:Number;
            private var time2:Number;

            private function toMeasure():void
            {
                for (var i:int = 0;i<30000;i++)
                {
                    trace (i);
                }
            }

            protected function main():void
            {
                time1= new Date().time;
                toMeasure();
                time2= new Date().time;
                trace ("ms:"+(time2-time1));
            }
+7

Source: https://habr.com/ru/post/1728959/


All Articles