Re: Number of operations per function

2016-12-23 Thread flex capacitor
Thanks. I read those blog posts in the past but had missed that one.

So when a company advertises last years device can do 1 teraflop and this
years device can do 2 teraflops that doesn't mean twice as fast or twice as
many FPS? It's only twice as fast if they are doing the same exact
operation as the first test (like only adds or only multiply operations)?


On Fri, Dec 23, 2016 at 5:40 AM, Vincent  wrote:

> Hi,
>
> I don't know if it can be useful but Jackson Dunstan wrote several
> articles about loop speed : http://jacksondunstan.com/articles/358
>
> Cheers
>
>
> Le 22/12/2016 à 22:20, flex capacitor a écrit :
>
>> 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> 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?
>>
>>
>


Re: Number of operations per function

2016-12-23 Thread Vincent

Hi,

I don't know if it can be useful but Jackson Dunstan wrote several 
articles about loop speed : http://jacksondunstan.com/articles/358


Cheers

Le 22/12/2016 à 22:20, flex capacitor a écrit :

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

Re: Number of operations per function

2016-12-22 Thread Alex Harui
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"  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;ifor (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?



Number of operations per function

2016-12-22 Thread flex capacitor
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