   Got Angelscript to work on the Iphone
  I got angelscript to work on the Iphone but the script parsing is so darn slowthat my application just shut down. I am using alot of scripts and they are pretty big.   
  Maybe compile to bytecode and only save/load that?Still, thats very cool!   ;  Cool stuff. Did you enable all the compiler optimizations when compiling AngelScript? Is there a profiler available in the iPhone SDK? If so the result of a run with profiling enabled would help greatly in determining what exactly it is that is taking the cpu cycles.Also, what is the result when running the test_performance tests?On my 600 Mhz ARM based platform I got:Performance testAngelScript 2.16.2---------------------------------------------TestBasicAngelScript 2.15.0   : 1.772 secsAngelScript 2.15.1 WIP    : 1.772 secsBuilding...Executing AngelScript version...Time = 18.873262 secs---------------------------------------------TestBasic2AngelScript 2.15.0   : .8570 secsAngelScript 2.15.1 WIP    : .8570 secsBuilding...Executing AngelScript version...Time = 11.769717 secs---------------------------------------------TestCallAngelScript 2.15.0   : 1.438 secsAngelScript 2.15.1 WIP    : 1.438 secsBuilding...Executing AngelScript version...Time = 21.096940 secs---------------------------------------------TestCall2AngelScript 2.15.0   : 2.513 secsAngelScript 2.15.1 WIP    : 2.513 secsBuilding...Executing AngelScript version...Time = 27.607861 secs---------------------------------------------TestIntAngelScript 2.15.0   : 0.4222 secsBuilding...Executing AngelScript version...Time = 4.634129 secs---------------------------------------------TestIntfAngelScript 2.15.0   : 2.631 secsAngelScript 2.15.1 WIP    : 2.631 secsBuilding...Executing AngelScript version...Time = 27.947712 secs---------------------------------------------TestMthdAngelScript 2.15.0   : 2.420 secsAngelScript 2.15.1 WIP    : 2.420 secsBuilding...Executing AngelScript version...Time = 25.588162 secs---------------------------------------------TestStringAngelScript 2.15.0   : 3.170 secsAngelScript 2.15.1 WIP    : 3.147 secsBuilding...Executing AngelScript version...Time = 28.163316 secs---------------------------------------------TestString2AngelScript 2.15.0   : 1.669 secsAngelScript 2.15.1 WIP    : 1.608 secsBuilding...Executing AngelScript version...Time = 15.944655 secsCoding up the first two as native functions, I got:Performance testAngelScript 2.16.2---------------------------------------------TestBasicAngelScript 2.15.0   : 1.772 secsAngelScript 2.15.1 WIP    : 1.772 secsBuilding...Executing Native version...Time = 0.696649 secs---------------------------------------------TestBasic2AngelScript 2.15.0   : .8570 secsAngelScript 2.15.1 WIP    : .8570 secsBuilding...Executing Native version...Time = 0.509283 secsSo a very rough estimate is that AS is about 20-30 times slower than native on ARM. I have no clue whether that is a good or bad result for a scripting engine. Exactly where all the cycles are going I don't know as I've been unable to do a competent code profiling session as of yet. I suspect that my JIT I'm working on will help a lot, however there might be other small things that AS does that the ARM cpu doesn't like. The TestCall functions for example use a minimal script so the bottleneck is likely the prepare statement.Another thing that differs between the native an AS version is the use of registers vs memory. If your ARM system has slow memory (or bus) then all the memory read/writes that AS require but a native version does not will hurt perf quite a bit. Again this is something a JIT will be able to improve as it understands when it actually needs to read/write stuff from/to memory whereas AS can not.   ;  That is really interesting. If that is the case, maybe angelscript is not the best thing to use for the Iphone. The problem is that right now my engine for the pc which is the same engine i am using on the iphone uses angelscript and the game i am porting over from the pc to the iphone needs to use the same scripts i was using on the pc. If angelscript is a problem, then i will need to either use lua or something else.   ;Quote:Original post by quarnster......The TestCall functions for example use a minimal script so the bottleneck is likely the prepare statement......I would say its the GetFunctionIdByDecl like the AngelScript doc says...   ;  Don't forget that the iPhone SDK agreement expressly forbids the use of interpreted code...   ;Quote:Original post by SudiQuote:Original post by quarnster......The TestCall functions for example use a minimal script so the bottleneck is likely the prepare statement......I would say its the GetFunctionIdByDecl like the AngelScript doc says...Have you read the code in question? GetFunctionIdByDecl is not part of the timed code http://angelscript.svn.sourceforge.net/viewvc/angelscript/trunk/sdk/tests/test_performance/source/test_call.cpp?revision=335int funcId = mod->GetFunctionIdByDecl("void TestCall()");printf("Executing AngelScript version...\n");double time = GetSystemTimer();int r;for( int n = 0; n < 10000000; n++ ){ctx->Prepare(funcId);r = ctx->Execute();if( r != 0 ) break;}time = GetSystemTimer() - time;;  FYI, for the testcall tests, if I compile with AS_NO_THREADS defined I get this:TestCallAngelScript 2.15.0   : 1.438 secsAngelScript 2.15.1 WIP    : 1.438 secsBuilding...Executing AngelScript version...Time = 9.392314 secs---------------------------------------------TestCall2AngelScript 2.15.0   : 2.513 secsAngelScript 2.15.1 WIP    : 2.513 secsBuilding...Executing AngelScript version...Time = 15.885782 secsIf I further remove the calls to asPushActiveContext/asPopActiveContext (are they really needed when not threading?) I get:TestCallAngelScript 2.15.0   : 1.438 secsAngelScript 2.15.1 WIP    : 1.438 secsBuilding...Executing AngelScript version...Time = 6.585667 secs---------------------------------------------TestCall2AngelScript 2.15.0   : 2.513 secsAngelScript 2.15.1 WIP    : 2.513 secsBuilding...Executing AngelScript version...Time = 14.225500 secsIn other words those specific tests become between 2-3 times faster.   ;  Is this using the native calling convention support that quarnster contributed? Or are you using generic calling conventions? Or in other words, can I add iPhone to the list of supported platforms with support for native calling conventions without lying? AngelScript FeaturesThe script compilation in AngelScript is likely slower than in Lua, but the execution of the scripts should be faster. This is because of the language design, i.e. statically typed versus dynamically typed.Would you be able to use pre-compiled bytecode, so that the compilation can be avoided at load time?Don't make any hasty decisions and switch to Lua before letting me try to help you improve the speed of AngelScript. I haven't focused a lot on optimizations in AngelScript, so there are bound to be lots of room for improvements in this area.;  Yes the native calling conventions do work. But just to be on the safe side i am using asCALL_GENERIC right now.   