🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Scripting language performance

Started by
13 comments, last by drslush 21 years, 1 month ago
I''ve been working on a little OO scripting language that can be customized for various applications (Something along the lines of lua I suppose), and I ran a little benchmark test. It seems that my scripting language runs about 450 times slower than an equivalent native function. How bad is this? Do I need to seriously rething my design? Can anyone tell me how this compares to other scripting languages?
Advertisement
Python is sometimes 100 times slower than the equivalent native stuff, but usually 20-80 times slower. So a single number (450) won't tell much, since scripting languages are slow in different areas than compiled languages. Maybe your scripting language is around 5-10 times slower than Python. (Python with JIT is a lot faster though)


[edited by - civguy on May 19, 2003 4:32:15 PM]
Also, you might find this useful. It compares the speeds of several languages.
450 to 1 isn''t too bad a ratio, for an unoptimized scripting language. Of course, it''s slow as heck--but as long as you aren''t, say, computing a few thousand digits of pi every frame, that''s most likely not a problem.

I see someone else has already posted a link to the Shootout, so I''ll forego that. But don''t be discouraged by the insanely slow performance of scripting languages--just keep in mind what you should do in a scripting language, and what you should do in C/C++.

How appropriate. You fight like a cow.
I''m really surprised that PHP came in so low. Kinda makes me wonder why the vast majority of interactive content on the web is PHP if it''s performance is so horrible
daerid@gmail.com
That shootout is weird. How can c++ technically be slower than c. If you take C source and compile it with a modern c++ compiler its at least the same speed, but most likely faster because the latest c++ compilers are way more optimized.

If they changed the source code than .. well .. than they instructed the computer to do additional things over the c version. Imho they should have made sure that the C and C++ version show the same speed, everything else looks iffy.
Well c/c++ and other related compilable languages are astoundingly fast so even being 450 times slower is still incredibly fast, especially if you aren''t doing some intense calculations which you normally don''t do with a scripting language.
Do some research into the System.CodeDom and System.CodeDom.Compiler namespaces that are part of the .NET framework.

Why bother writing your own OO scripting language when you can just use a real OO language compiled and invoked at runtime?

I'm using CSharpCodeProvider as a scripting language

[edited by - Nypyren on May 20, 2003 3:46:14 AM]
quote: Original post by Xalon
That shootout is weird. How can c++ technically be slower than c.
My quess is that they do it "the C++ way" and "the C way", not by compiling C code with a C++ compiler. For example:
char text[100];strcpy(text, "etrhseth");strcat(text, "e5uyet"); 

That is a LOT faster than:
string text = "etrhseth";text += "e5uyet"; 

At least that''s the result I got the last time I compared their performance. So if C''s low level way of doing things happens to be faster than C++''s safe way, it''s only fair to say that C is faster. That test doesn''t measure program reliability, readibility and other things where the C++ solution excels.
civguy, the test you do is compleatly unfair.

You tell your c compiler how much memory to reserve and you let your cpp compiler guess.

string text;
text.reserve( 100 );
text += "etrhseth";
text += "e5uyet";

would be equivalent code.

Also this above code does a LOT more than your two c lines.

Just go ahead and append a

char text2[100];
strcpy(text2,text);

or

string text2 = text;

and profile that. I''d say on 10 out of 9 std implementations c++ would be faster because of reference counting.

However. The first code you posted is also perfectly legal c++ code. Profiling both will most likely yield same results and that was my point.

This topic is closed to new replies.

Advertisement