Reputation: 9
i have 3 files x.lua, y.lua and main.lua. These files doing some mathematics operations (increment and decrement number). When i run the command
lua main.lua
is much faster than
luac -o main.luac -s x.lua y.lua main.lua
Please can you help me why is bytecode slower?
Upvotes: 0
Views: 295
Reputation: 29571
They are very different operations:
lua main.lua
: this does
luac -o main.luac -s x.lua y.lua main.lua
: this does:
Writing a file (operation 2) is a slow operation, involving disk access, dumping memory chunks etc; it will be significantly slower than executing some bytecode (operation 1), unless latter is compute intensive.
Upvotes: 1
Reputation: 72352
I'm guessing that main.lua
does dofile("x.lua")
or require"x"
and the same for y.lua
.
In that case, the second form runs x.lua
and y.lua
twice.
Upvotes: 3