lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Mar 19, 2007, at 12:12 AM, Lothar Scholz wrote:

This has nothing to do what i measured or find usefull in real life. In embedded scripting 

(as i have used it and seen)  you build up a huge universe of your own objects and then 

you need to call this many times from the Lua glue code.


You are doing functions calls without any OO behind. Thats not realistic. A serios problem is always to 

move from script<->C level. I'm was amazed to see how slow this is in many languages, including Java.


I have my own Lua and Python extensions which implements the SHA-256 hash algorithm , which is written in C. It has an object-oriented interface, so your write:

require 'sha256'

local h = sha256.new()
for i = 1, N do
   h:update("")
end

A million iterations end up taking 750 ms. That includes searching the metatable for "update", type validation of the object and the argument etc.

So the overhead of a method call to an object implemented in C is about 750 nanoseconds. About equivalent to 2 native Lua method calls using a trivial object hierarchy. I don't believe that's excessive. Python is slower again, around 1200 ns/call.

BTW: the machine I'm doing this on is a 2.5 year old PowerPC Mac laptop (PowerPC 7447A), which is a processor intended for embedded work. It's probably fairly similar to what you'd find in a higher-end game console. This should be faster on the current crop of desktop processors with their branch prediction and speculative executions tricks.

Tschüß,


--
Gé Weijers