I was just looking into methods of scripting inside of my mbed application, and decided I'd give Lua a shot to see how well it works. This is not eLua but just the Lua interpreter and language embedded inside my app.
To build Lua it required a handful of tweaks to the source to exclude some functions that are not available (feof, time). The entire thing uses 105k of flash. That includes all of the debugging, file IO, and parser / compiler. It should be possible to trim that down to about half that size, especially if the parser is not needed and it will just execute existing bytecode.
Performance-wise I was able to call my C defined LED routine twice (on then off) 1,000,000 times in 19.156 seconds. That's 52khz. That includes all the overhead of calling from Lua to my C routine.
Here's the test lua code:
for i = 0, 1000000, 1 do
mbed.LED(true)
mbed.LED(false)
end
For comparison, the C version of that executes in 0.29 seconds:
for (int i=0; i<1000000; i++) {
myled=true;
myled=false;
}
Lua can count to 1,000,000 on my device (F401RE, stock clock speed) in 10.239 seconds (not calling back into the C code).
I can post my C code that sets up and calls into Lua if anyone is interested. It's very easy to use.
I was just looking into methods of scripting inside of my mbed application, and decided I'd give Lua a shot to see how well it works. This is not eLua but just the Lua interpreter and language embedded inside my app.
To build Lua it required a handful of tweaks to the source to exclude some functions that are not available (feof, time). The entire thing uses 105k of flash. That includes all of the debugging, file IO, and parser / compiler. It should be possible to trim that down to about half that size, especially if the parser is not needed and it will just execute existing bytecode.
Performance-wise I was able to call my C defined LED routine twice (on then off) 1,000,000 times in 19.156 seconds. That's 52khz. That includes all the overhead of calling from Lua to my C routine.
Here's the test lua code:
For comparison, the C version of that executes in 0.29 seconds:
Lua can count to 1,000,000 on my device (F401RE, stock clock speed) in 10.239 seconds (not calling back into the C code).
I can post my C code that sets up and calls into Lua if anyone is interested. It's very easy to use.