🔒 Locked
Scripting language performance
Advertisement
Original Post
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?
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]
[edited by - civguy on May 19, 2003 4:32:15 PM]
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 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.
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.
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]
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: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:
Original post by Xalon
That shootout is weird. How can c++ technically be slower than c.
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.
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.
I''ve gotten it to about 300 times slower than native, so I don''t feel too bad. My scripting language is doing a ton of stuff dynamically, things that can only be done in a scripting language, so I think I''ll be happy with the fact that my language runs 3x slower than python. I''m not doing any super complex stuff with it, its just meant to be a scripting language for an RPG or some similar game.
quote:
Original post by Xalon
civguy, the test you do is compleatly unfair.
...
Also this above code does a LOT more than your two c lines.
It''s as unfair as that site comparing Python and C++. Python is doing a lot more than C++ is.
Also, I find it hard to believe that C++ compilers are better at optimizing C code than C compilers. C compilers have quite a few years on C++ compilers, not to mention that C++ compilers have a lot more to deal with. Also, C++ compilers require more hints in the code (like making you cast the return from malloc). Plus, the idea that you can just feed C code to a C++ compiler isn''t quite true. There are enough (relatively subtle) differences that this can fail (for example, the linking rules for inline functions are different in C and C++).
quote:
Original post by Nypyren
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
That''s one cool idea! I''ll give it a try.
Regards,
Andre
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement