Skip navigation
RowerRod
Currently Being Moderated

Speed Test

Feb 25, 2012 8:02 AM

Hello,

I have written a JSON Parser / Evaluator. I wanted to make it faster by using Alchemy. Here's the result...

 

/********************************************************************* ***********************************************/

 

var loader:CLibInit = new CLibInit;

var lib:Object = loader.init();

lib.init(E);

 

 

/********************************************************************* ***********************************************/

 

                              var z:int = 0;

                              var t:Number, i:String;

 

                              t = new Date().time;

 

                              while (z < 100)

                                        {

                                        var fff:Object = Express.object('a:true;b:false;c:0.555;d:asdf;e:abc;array:[1,2,3];obj ect:{one:true}');

                                        z++;

                                        }

 

                              trace(new Date().time - t);

 

 

                              trace('\n\nAS3', fff, typeof fff, '\n');

 

                              for (i in fff)

                                        {

                                        trace(escape(i), fff[i], 'type:', typeof fff[i]);

                                        }

 

                              trace('\n');

                              /************************/

 

                              z = 0;

                              t = new Date().time;

 

                              while (z < 100)

                                        {

                                        var eee:Object = lib.object('a:true;b:false;c:0.555;d:asdf;e:abc;array:[1,2,3];object: {one:false}');

                                        z++;

                                        }

 

                              trace(new Date().time - t);

 

                              trace('\n\nALC', eee, typeof eee, '\n', eee.object.one, typeof eee.object.one);

 

                              for (i in eee)

                                        {

                                        trace(escape(i), eee[i], 'type:', typeof eee[i]);

                                        }

 

/********************************************************************* ***********************************************/

 

 

[TRACE]

 

14 //ms

 

 

AS3 [object Object] object

 

 

object [object Object] type: object

d asdf type: string

array 1,2,3 type: object

e abc type: string

a true type: boolean

b false type: boolean

c 0.555 type: number

 

 

650 //ms

 

ALC [object Object] object

false boolean

object [object Object] type: object

d asdf type: string

array 1,2,3 type: object

e abc type: string

a true type: boolean

b false type: boolean

c 0.555 type: number

 

/////////////////////////////////////////////////////////////

 

What is wrong??? that's not really fast in my opinion. sorry for my english

 

regards

 
Replies
  • Currently Being Moderated
    Feb 26, 2012 10:37 AM   in reply to RowerRod

    Its not realy a mistage.

    Cost of call to alhemy libs is hight.

    Please do loop in alchemy, then you can see boost. In My opionion alhemy works better with big bata structures, like ByteArray, some simulations, etc... not for that simple operation like this,

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 28, 2012 6:48 AM   in reply to trzecieu

    After playing around with the new JSON Parser in FP11 I noticed a big increse in performance. The same algorithm only takes 0ms.

    Unlike com.adobe.serialization.JSON, this new JSON class is using a native 'AS3 function'.

     

    The same speed i can only get with haxecpp but as far as i know there is no good and clean way to implement c++ in the Flash Player.( sandbox i assume... )

    I need to write native AS3 functions. Alchemy does not for work my case because you say 'cost of call to alchemy libs is high'!

     

    thanks, much appreciate

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points