Some Flash micro-benchmark results

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Some Flash micro-benchmark results

James W. Hofmann
Hi list, I've been collecting benchmarks for Flash 10 over the last  
few days, some interesting results....some of this you might have  
already known but I couldn't find the info myself...

-The built-in Std.int() is extremely slow, but you can do better than  
built-in performance rolling your own integer division(4-5x) and  
truncation(10x after eliminating bounds checks)
-Setting and switching on Enums is quite slow - 170x as slow as a  
float comparison :(
-Field lookups have interesting behavior:

Class fields are fastest
Class fields used as Dynamics are second fastest(10x)
Typedefs, anonymous objects using Dynamics, and Reflect.field()  
lookups of typed or Dynamic class fields compete for third(16x)
Classes marked "implements Dynamic" using undeclared fields are  
slowest of the ones I tried(22x).

Anyway, I posted the code I used for this:
http://haxe.org/doc/snip/_flash_benchmarks?lang=en

Let me know if my methodology was stupid/ignorant :)

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Some Flash micro-benchmark results

Mario Carbajal
The test for Std.int is flawed, you are assigning Std.int to a toInt variable and then using that instead, then the compiler cant inline the Std.int body. Function calls are slow, Std.int isnt, Std.int usually translates to a single toInt opcode in the AVM2 bytecode.

This are my results when running your benchmarks:
Microbench.hx:390: [divide,21]
Microbench.hx:390: [dividefastfloor,97]
Microbench.hx:390: [intdivide,24]
Microbench.hx:390: [dividefloor,656]
Microbench.hx:390: [dividefloor2,21]

dividefloor2 is the following function:

public inline function dividefloor2()
{
      var z = 0;
      while (z<ITERCOUNT)
      {
           n = Std.int( m / z );
           z++;
      }
}

On Thu, Apr 1, 2010 at 6:20 AM, James Hofmann <[hidden email]> wrote:
Hi list, I've been collecting benchmarks for Flash 10 over the last few days, some interesting results....some of this you might have already known but I couldn't find the info myself...

-The built-in Std.int() is extremely slow, but you can do better than built-in performance rolling your own integer division(4-5x) and truncation(10x after eliminating bounds checks)
-Setting and switching on Enums is quite slow - 170x as slow as a float comparison :(
-Field lookups have interesting behavior:

Class fields are fastest
Class fields used as Dynamics are second fastest(10x)
Typedefs, anonymous objects using Dynamics, and Reflect.field() lookups of typed or Dynamic class fields compete for third(16x)
Classes marked "implements Dynamic" using undeclared fields are slowest of the ones I tried(22x).

Anyway, I posted the code I used for this:
http://haxe.org/doc/snip/_flash_benchmarks?lang=en

Let me know if my methodology was stupid/ignorant :)

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Some Flash micro-benchmark results

back2dos
In reply to this post by James W. Hofmann
James Hofmann wrote:

> Hi list, I've been collecting benchmarks for Flash 10 over the last
> few days, some interesting results....some of this you might have
> already known but I couldn't find the info myself...
>
> -The built-in Std.int() is extremely slow, but you can do better than
> built-in performance rolling your own integer division(4-5x) and
> truncation(10x after eliminating bounds checks)
> -Setting and switching on Enums is quite slow - 170x as slow as a
> float comparison :(
> -Field lookups have interesting behavior:
>
> Class fields are fastest
> Class fields used as Dynamics are second fastest(10x)
> Typedefs, anonymous objects using Dynamics, and Reflect.field()
> lookups of typed or Dynamic class fields compete for third(16x)
> Classes marked "implements Dynamic" using undeclared fields are
> slowest of the ones I tried(22x).
>
> Anyway, I posted the code I used for this:
> http://haxe.org/doc/snip/_flash_benchmarks?lang=en
>
> Let me know if my methodology was stupid/ignorant :)
>
please also note, results vary a lot depending on whether you compile
for debug or release and - more importantly - which runtime you use.
debug player can be upto 10 times slower for some operations. also speed
varies between flash player versions.

greetz
back2dos

--
haXe - an open source web programming language
http://haxe.org