diff options
Diffstat (limited to 'doc/ext_ffi.html')
-rw-r--r-- | doc/ext_ffi.html | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html index e8e2a62b..f496b51b 100644 --- a/doc/ext_ffi.html +++ b/doc/ext_ffi.html | |||
@@ -73,8 +73,8 @@ The FFI library is tightly integrated into LuaJIT (it's not available | |||
73 | as a separate module). The code generated by the JIT-compiler for | 73 | as a separate module). The code generated by the JIT-compiler for |
74 | accesses to C data structures from Lua code is on par with the | 74 | accesses to C data structures from Lua code is on par with the |
75 | code a C compiler would generate. Calls to C functions can | 75 | code a C compiler would generate. Calls to C functions can |
76 | be inlined in the JIT-compiled code, unlike calls to functions bound | 76 | be inlined in JIT-compiled code, unlike calls to functions bound via |
77 | via the classic Lua/C API. | 77 | the classic Lua/C API. |
78 | </p> | 78 | </p> |
79 | <p> | 79 | <p> |
80 | This page gives a short introduction to the usage of the FFI library. | 80 | This page gives a short introduction to the usage of the FFI library. |
@@ -253,14 +253,17 @@ would consume 40 Megabytes in plain Lua (on x64). | |||
253 | Next, performance: the pure Lua version runs in 9.57 seconds (52.9 | 253 | Next, performance: the pure Lua version runs in 9.57 seconds (52.9 |
254 | seconds with the Lua interpreter) and the FFI version runs in 0.48 | 254 | seconds with the Lua interpreter) and the FFI version runs in 0.48 |
255 | seconds on my machine (YMMV). That's a factor of 20x faster (110x | 255 | seconds on my machine (YMMV). That's a factor of 20x faster (110x |
256 | faster than with plain Lua). | 256 | faster than the Lua interpreter). |
257 | </p> | 257 | </p> |
258 | <p style="font-size: 8pt;"> | 258 | <p style="font-size: 8pt;"> |
259 | The avid reader may notice that converting the pure Lua version over | 259 | The avid reader may notice that converting the pure Lua version over |
260 | to use array indexes for the colors (<tt>[1]</tt> instead of | 260 | to use array indexes for the colors (<tt>[1]</tt> instead of |
261 | <tt>.red</tt>, <tt>[2]</tt> instead of <tt>.green</tt> etc.) ought to | 261 | <tt>.red</tt>, <tt>[2]</tt> instead of <tt>.green</tt> etc.) ought to |
262 | be more compact and faster. This is certainly true (by a factor of | 262 | be more compact and faster. This is certainly true (by a factor of |
263 | ~1.7x), but the resulting code would be less idiomatic and rather | 263 | ~1.7x). Switching to a struct-of-arrays would help, too. |
264 | </p> | ||
265 | <p style="font-size: 8pt;"> | ||
266 | However the resulting code would be less idiomatic and rather | ||
264 | error-prone. And it still doesn't get even close to the performance of | 267 | error-prone. And it still doesn't get even close to the performance of |
265 | the FFI version of the code. Also, high-level data structures cannot | 268 | the FFI version of the code. Also, high-level data structures cannot |
266 | be easily passed to other C functions, especially I/O functions, | 269 | be easily passed to other C functions, especially I/O functions, |