After finding out that Lua was about 2 times as fast as AngelScript I started thinking more about how to improve the performance. I already implemented the easiest optimizations which has improved the performance with about 30-50%. I have plenty of ideas for other changes that might improve the performance even more, and I'm certain that I will be able to make AS at least as fast as Lua. AngelScript has the advantage of being strongly typed and the ability to call C/C++ functions directly without wrapper functions. The ultimate optimization would be to compile directly to machine-code, but that is a step I'm not ready to take yet. That part will probably be done through a plug-in-able JIT compiler or something like that.
I'm planning on making these optimizations gradually over time, as I would otherwise have to stop further development of the library features, which is not something that I want to do.
Here are the changes for the latest WIP:
- bug fix: Switch-case didn't work correctly if the cases were not ordered in ascending order (thanks Dmitry "RCL" Rekman)
- bug fix: The ternary operator ?: didn't release temporary variables as it should, causing an assert failure in the debug version (thanks Dmitry "RCL" Rekman)
- bug fix: Passing string constants to condition operator would cause an assertion failure. (thanks Joe "Desdemona" Wright)
- Added support for asCALL_CDECL_OBJFIRST (thanks Tristan "Kurioes" Hartskeerl)
- Improved performance of byte code execution with about 30%
Author of AngelScript
[Edited by - WitchLord on September 14, 2004 7:44:05 PM]
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
I tried 1.9.1-WIP1 and I am pretty glad with the results. Performance gain is not just 30%-50% as you state. Right now the results are:
Lua: 20.499574 sec AngelScript: 23.772902 sec
So it is nearly the same!!
I dunno why there is such a great performance boost. Older version performed nearly 2 times slower.
By the way, I did a mistake and AS version of performance test was not 100% identical to Lua version (there is one 'multiply' operation more each iteration, and the loop is one iteration less than Lua version). For tests to be identical, '*=' should be replaced with '=' in func3() for AS version and condition in 'for' loop should be changed from '<' to '<=' to match Lua's 'for'. I thought that could be the reason affecting performance, but even with the 100% identical tests, older version performs nearly 2 times as slow as Lua:
(Results for 1.9.0, 'tweaked' by me (ExecuteNext() rearranged, bcSize changed to enumerants), identical script )
Well, that is certainly great news. [smile] Already almost as fast as Lua, and I haven't even applied all the optimizations that I thought of. That was just the most simplest of them.
I don't know either why you get such an incredible performance improvement. When I measured the performance difference between 1.9.0 and 1.9.1 WIP1 it was only about 30%-50% faster. Could it be that you changed the compiler flags?