[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ruby?
- From: "Nick Trout" <nick@...>
- Date: Tue, 26 Sep 2000 12:28:22 +0100
> I have seen quite a few performance comparisions of Lua vs other scripting
> languages, but has anyone done corresponding C/C++ benchmarks?
>
> The current (scripting language) benchmarks are useful for answering the
> question: "I need a scripting language - which one should I use?".
> However, once you have chosen the scripting language(obviously Lua!), then
> you start to ask the question "How much is the perfomance going to change
if
> I move this C++ function into Lua?"
How good are you at writing Lua code? :-) Examples of optimisations would
be nice. How do you get the best from the language. Would be a nice section
to have in the manual (it might be there already? :-/ )
> - so you can work out where to draw the
> line between your C++ and scripting code. This is obviously going to
depend
> on the actual code involved. However, if anyone is going to run any new
> benchmarks, I'd be interested in some C/C++ timings too!
Whats the point? The fact is Lua is fast and has a fast,easy host/script
interface. Whether your implementaion of whatever you have written is fast
enough is entirely subjective and up to you to fix! :-) You may even decide
to let code run slower in script (for the advantage of having tables to
program with) and choose to speed up something else (plenty of scope I'm
sure!).
Hints on how to write fast Lua code to take advantage of the language would
be good. Unless someone asks a question here or shares their extensive
knowledge of Lua these optimisations will remain secret to most casual
users, who may, as game scripters (and poor programmers - eg. unable to
understand the VM), end up writing most of the Lua code...
eg. Put all of these in a doc and publish it!!! :-)
>Please could you explain why local variables are so much faster than
>globals.
Globals need a table look-up. Locals are indices into the stack.
Here is the relevant section of lvm.c:
case OP_GETLOCAL: {
*top++ = *(base+GETARG_U(i));
break;
}
case OP_GETGLOBAL: {
L->top = top;
*top = *luaV_getglobal(L, kstr[GETARG_U(i)]);
top++;
break;
}
N