flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Number of operations per function
Date Thu, 22 Dec 2016 22:43:07 GMT
Assuming you only really care about performance, I would suggest writing a
test harness that runs these patterns 100,000 times (or more) and run at
least 5 timings and look for convergence in the numbers.

Things may have changed since I worried about CPU cycles in detail, but
for Intel X86 CPUs, a multiply was much more expensive than an add, so no,
not all operations are equal.  Also consider that the operations in the
body of the function are likely to overwhelm the differences in speed of
the three patterns.

Different machines also have different sizes and speeds of instruction and
memory caches, so the operations in the body can affect whether the
operations in these patterns are in-cache or not.

IIRC, operations on Flash Player display list objects are way more
expensive than operations on regular objects, so not only do you need to
know how many memory ops there are, you have to know what you are
accessing.

In short, IMO, the answer is too complex to care about in detail.  Run a
harness on the target device and see what you get.

My 2 cents,
-Alex

On 12/22/16, 1:20 PM, "flex capacitor" <flexcapacitor@gmail.com> wrote:

>I have a case where I can write a function a few different ways and since
>Flash Player doesn't provide a microtime only getTimer() I'm trying to
>find
>a way to get the number of operations that are occurring in each different
>method.
>
>For example, I have 3 different ways to get the results I want
>
>for (var i:int;i<array.length;i++) {}
>for (var prop in object) {}
>for each (value in object) {}
>
>each gets the result I'm looking for. But what I want to know is if there
>is a way to know how many operations are being run on the CPU from a
>specific statement, a specifc block of code or a specific function. I know
>about the Flash Builder profiler and Scout but I see only sample time
>which
>I'm not looking for just operation counts.
>
>I might be running this on a microcontroller that has limited CPU. So
>instead of 1 teraflop I might have 1000 operations.
>
>I guess that also begs the question are all operations equal at the CPU
>level?

Mime
View raw message