Hi,
I understand that AS3 is going to be slower than c of course, BUT why 4 times slower. That seams like too much with a simple test like this where no object or string manipulation is happening, only function call and integer comparison, increment plus one modulo operator.
I have a situation in Box2D where when you have a lot of complex dynamic objects with a lot of fixtures Box2D is calling one particular function like 7000, 10000 and even 20000 times. That is why I have designed a very simple test to only test function call performance.
I have created this test for ActionScript 3, C, C#, Java and ActionScript.
This is the code for ActionScript 3:
https://pastebin.com/Hy9Kcc4h
Test completes on my machine in 15 seconds. I am using AIR SDK 30, Windows 10 and Flash Builder 4.7.
Also this result is for release build. Result is the same for Win 32 bit Captive release build and release build swf run from Flash Standalone Player version 30 (not debug player);
This is the code for C:
https://pastebin.com/h6j6VXtA
I have used MinGW compiler. Value of CLOCKS_PER_SEC on my machine is 1000
This test completes for about 4 seconds. I have tested this by running compiled exe file from the command line.
This is the code for C#:
https://pastebin.com/66eGGXE0
I have used Visual Studio Express 2017. I have created console application. On my machine this test completes for about 2 seconds. Which was very surprising because it seams faster than pure C. I tested this by running dotnet FunctionPerformanceTest.dll in the command line.
This is the code for Java:
https://pastebin.com/RwKSUDQs
This was the biggest surprise for me because this test completes in about 1 second which is the fastest of all tests. I run this by running java FunctionPerformanceTest in the command line.
This is the code for JavaScript:
https://pastebin.com/h6zQeBWu
This was of course the slower test of all. It completes after about 29 seconds. I have run this from npm with node FunctionPerformanceTest.js command.
So I understand that Action Script 3 is going to be slower than C or Java but why is slower more than 4 times?
Does this seams like too much for you as well?
Will there ever be any optimizations to speed things like this in AS3?