.NET Engineer and Software Architect
Actionscript vs Playscript(compiler) vs C#(Monotouch) vs ObjC
Actionscript vs Playscript(compiler) vs C#(Monotouch) vs ObjC

Actionscript vs Playscript(compiler) vs C#(Monotouch) vs ObjC

This is the test to check relative difference in performance on mobile device.

I compared:

  • Actionscript 3 code compiled with ASC2 (AIR 3.6)
  • Actionscript 3 code compiled with Playscript-mono compiler
  • C# code compiled with Playscript-mono compiler (Monotouch)
  • Objective C code

Results (on iPad 3):

  • AS3 (ASC2) – 390 milliseconds
  • AS3 (Playscript) – 810 milliseconds
  • C# – 800 milliseconds
  • ObjC – 460 milliseconds

Objective C

-(void)testCos
{
    NSDate* date = [NSDate date];

    for (int j = 0; j & lt; 2000000; j++) {
        self.d = cos(j);
    }

    float timePassed_ms = [date timeIntervalSinceNow] * -1000;

    self.myLbl.text = [NSString stringWithFormat:@"%f", timePassed_ms];
}

C#

private void cos()
{
    DateTime t = DateTime.Now;

    for (int j = 0; j & lt; 2000000; j++) {
        d = System.Math.Cos(j);
    }

    TimeSpan myDateResult = DateTime.Now - t;

    myLbl.Text = myDateResult.TotalMilliseconds.ToString();
}

Actionscript 3

public function cos():void
{
    var t:Number = getTimer();

    for (var j:int = 0; j & lt; 2000000; j++)
    {
        d = Math.cos(j);
    }

    time = getTimer() - t;
}

7 Comments

    1. ingwe

      Well, I do not think so. First of all, the test is very synthetic and does not represent real-world situations. I just wanted to perform very general quick test, to get the overall idea of performance between Actionscript and Playscript (and others are for reference). Plus, I am not ObjC developer, and my sample code may not be optimized (for example, i found out that the performance of that ObjC code can be much slower/faster depending on the way you declare variable). But I believe that ASC2 is very optimized for simple Math computations.

    1. ingwe

      I am not sure I understand you. I see no casting in the code. As to the output in AS3 version – the output is saved in “time” variable, which can be accessed in any way you want (you can trace it or put into label).

      1. dto

        …i think he refers to the EXTRA call in
        Objective-C
        self.myLbl.text = [NSString stringWithFormat:@”%f”, timePassed_ms];

        C#
        myLbl.Text = myDateResult.TotalMilliseconds.ToString();

        To make it fair, why not do a
        AS3
        var string_Time:String = time.toString();

        to have that extra call in AS3?

        Or to remove the extra calls from C# and Objective-C, and get the result from outside the function cos?

    2. ryan

      I dont think it matters as the impression (and cast) happen after the time is calculated. Using the value elsewhere will not change the value.

Comments are closed.