|
On Mar 19, 2007, at 12:12 AM, Lothar Scholz wrote:
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é -- Gé Weijers |