summaryrefslogtreecommitdiff
path: root/doc/ext_ffi.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ext_ffi.html')
-rw-r--r--doc/ext_ffi.html11
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
73as a separate module). The code generated by the JIT-compiler for 73as a separate module). The code generated by the JIT-compiler for
74accesses to C data structures from Lua code is on par with the 74accesses to C data structures from Lua code is on par with the
75code a C compiler would generate. Calls to C functions can 75code a C compiler would generate. Calls to C functions can
76be inlined in the JIT-compiled code, unlike calls to functions bound 76be inlined in JIT-compiled code, unlike calls to functions bound via
77via the classic Lua/C API. 77the classic Lua/C API.
78</p> 78</p>
79<p> 79<p>
80This page gives a short introduction to the usage of the FFI library. 80This page gives a short introduction to the usage of the FFI library.
@@ -253,14 +253,17 @@ would consume 40&nbsp;Megabytes in plain Lua (on x64).
253Next, performance: the pure Lua version runs in 9.57 seconds (52.9 253Next, performance: the pure Lua version runs in 9.57 seconds (52.9
254seconds with the Lua interpreter) and the FFI version runs in 0.48 254seconds with the Lua interpreter) and the FFI version runs in 0.48
255seconds on my machine (YMMV). That's a factor of 20x faster (110x 255seconds on my machine (YMMV). That's a factor of 20x faster (110x
256faster than with plain Lua). 256faster than the Lua interpreter).
257</p> 257</p>
258<p style="font-size: 8pt;"> 258<p style="font-size: 8pt;">
259The avid reader may notice that converting the pure Lua version over 259The avid reader may notice that converting the pure Lua version over
260to use array indexes for the colors (<tt>[1]</tt> instead of 260to 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
262be more compact and faster. This is certainly true (by a factor of 262be 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;">
266However the resulting code would be less idiomatic and rather
264error-prone. And it still doesn't get even close to the performance of 267error-prone. And it still doesn't get even close to the performance of
265the FFI version of the code. Also, high-level data structures cannot 268the FFI version of the code. Also, high-level data structures cannot
266be easily passed to other C&nbsp;functions, especially I/O functions, 269be easily passed to other C&nbsp;functions, especially I/O functions,