Jump to content
  • Advertisement
Sign in to follow this  
brightening-eyes

AngelScript execution speed?

This topic is 698 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello,
i wanted to test AngelScript execution speed, so, i've executed a loop from -100000 to 100000, in C++, the execution took about 37.7 seconds, but in AngelScript, it took about 96.3 seconds
i don't know, the AngelScript is eaven slower than lua (from other tests that i've read)


this is the script which is executed on the AngelScript:

void main()
{
InitTimer();
for(auto i=-100000;i<=100000;i++)
{
cout<<i<<"\n";
}
cout<<"\nexecution success\n";
cout<<"the execution took "+GetTime()+" seconds\n";
}
note that C++ streams must be registered with AngelScript
also note that, systimer in basic compression library is used

and, this is the C++ code
#include <iostream>
#include <bcl/systimer.h>

using namespace std;
int main()
{
InitTimer();
for(auto i=-100000;i<=100000;i++)
{
cout<<i<<"\n";
}
cout<<"\nexecution success\n";
cout<<"the execution took "<<GetTime()<<" seconds\n";
}

Share this post


Link to post
Share on other sites
Advertisement

This is a bad way to benchmark performance; you spend more time on outputting the variables to the console, than doing anything useful. This doesn't make any sense unless your application is meant to print tons of data to the console.

 

Try doing something that doesn't involve IO operations, that'll give you a better idea about execution performance. Like, write a micro ray-tracer, that intersects against spheres.

Share this post


Link to post
Share on other sites

ok, this is fibonacci test which i got from codeplea.com and modified that on the sandbox, which is executed on 261.941 seconds

int fibR(int n)
{
    if (n < 2) return n;
    return (fibR(n-2) + fibR(n-1));
}

int fibI(int n)
{
    int last = 0;
    int cur = 1;
    --n;
    while(n > 0)
    {
        --n;
        int tmp = cur;
        cur = last + cur;
        last = tmp;
    }
    return cur;
}


void main()
{
InitTimer();
    const int N = 43;
    cout<<"fib: "+fibR(N);
    cout<<" = "+fibI(N);
    cout<<"\n";
cout<<"the execution took "+GetTime()+" seconds\n";
}
also, i've forgot to say my computer information that i've tested these:
windows 7 32 bit ultimate, 2 gb ram, intel (r) 2.90 GHZ cpu
some applications running on background such as my screen reader, skype, etc

Share this post


Link to post
Share on other sites
What is the actual question? Angelscript is slower than C++? That's not a surprise.

Is there an actual problem with the obvious fact that a scripting language can't quite keep up with a static binary from an optimizing C++ compiler? I daresay no. The applications and requirements are entirely different. You use Angelscript not because it's super fast, but because you want/need a scripting language.

Running benchmarks with millions of iterations is nice to get an idea about the byte code interpreter's speed, but is somewhat meaningless, as is running I/O benchmarks that merely measure the speed of iostream.

That's not what one normally uses scripting for. You don't use scripting to run high performance computing tasks (you can do that, it's just not what people do normally). Try benchmarking script calls and calling back into native code (which is what you do almost all the time).

Share this post


Link to post
Share on other sites

If AngelScript were as fast as your initial post claims it to be, i.e. 2.5 times slower than C++, it would likely be the fastest scripting language known to man. If, when bringing up Lua, you're thinking of this benchmark, take some time to actually read what it says and you'll find out that AngelScript performance was tested without a JIT compiler and compared against JIT-compiled Lua. Not to discredit the author, as neither could I get the only known AngelScript JIT compiler to work, but that is not a fair fight. Putting AngelScript up against C++, a language designed from the beginning to end to be efficient, whose compilers had decades to improve their optimization, is even less of a fair fight. Perhaps you ought to consider that the intended use of AngelScript does simply not require great speed. You're not supposed to use it to carry complicated calculations and find undiscovered prime numbers; it's a scripting language, use it to make things happen in games and stuff.

Share this post


Link to post
Share on other sites

i don't know, the AngelScript is eaven slower than lua

Almost every scripting language is slower than Lua. Lua is pretty much the fastest interpreted language around (without JIT). With the addition of LuaJIT, it's unnaturally fast.

You should expect "scripting languages" to be 2x to 20x slower than C.
They trade speed for other benefits.

Share this post


Link to post
Share on other sites

ok, i don't know why lua is so fast, with a simple syntax and 100 kb of interpreter, which is only in ansi C (luajit as far as i know, turn's the code into asm which make's it so fast)

but anyway, for fibonacci, the AngelScript is a little bit slow (i don't want to compair it with c because c work's completely different from AngelScript and it is compiled to native code, not byteCode)

i think, AngelScript's byteCode must be optimized more

Share this post


Link to post
Share on other sites

How much faster do you think AngelScript should be? 10% faster? 50% faster? Twice as fast? 10 times faster? :)

 

If you have any suggestions for how to optimize the code I would be very interested in hearing that. 

 

It's so funny (but also frustrating) when AngelScript is compared with Lua. I would love to have the resources that the team behind Lua has. You do know that Lua was invented back in 1993 by a team at a university and is still maintained by that same university (PUC-Rio in Brazil) and has actual investment money behind it? AngelScript on the other hand was invented by me in 2003 and is maintained by me with zero investment money? I've been working on AngelScript on my spare time for 13,5 years now. While some of the code has been contributed by community members it is practically a work done by a one-man-team. 

 

All things considered I think AngelScript is comparing quite well to other scripting libraries out there (including Lua). 

 

PS. Have you tried Blind Mind's JIT compiler for AngelScript? Perhaps it will allow you to get the performance you want.

Share this post


Link to post
Share on other sites

All things considered I think AngelScript is comparing quite well to other scripting libraries out there (including Lua). 

 

I think AngelScript is awesome and it's plenty fast for a lot applications.  I've done some testing versus Python in the past and it was much faster.  I think one of the best things and maybe overlooked feature of AngelScript is how easy it is to integrate into an application.  I've only used a few scripting engines but AngelScript is by far the easiest way to add scripting to a C++ application.

 

Two thumbs up and thanks for all your hard work!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!