The problem:
I have been testing two types of large files (roughly 20MB).
The first is a string file with around 4000 functions in it like:
function dostuff1()
<simple lua script>
end
function dostuff2()
<simple lua script>
end
And so on. The functions themselves are not overly important, but each one has very specific important simple operations in them.
The second file is simply a bytecode built version of the text file using:
luajit -b testfile1.lua testfile1.out
Then I test each file (load times) for each of them into their own env using:
local env = {}
local chunk = loadfile( filename, 'bt', env )
assert(pcall(chunk()))
The string files are significantly faster to load and process than the bytecode files. Which seems counter to what I would expect. Heres a small sample of comparisions. Note: some files have more complex functions in them than others (hence the time differences).
String files:
'# File Load+Run: ' 'test.tbl1' ' Time: ' 0.72784 ' Size:' 20877534
'# File Load+Run: ' 'test.tbl2' ' Time: ' 0.686193 ' Size:' 20880495
'# File Load+Run: ' 'test.tbl3' ' Time: ' 1.109813 ' Size:' 20824589
'# File Load+Run: ' 'test.tbl4' ' Time: ' 1.582231 ' Size:' 20827788
Bytecode files:
'# File Load+Run: ' 'test.out1' ' Time: ' 0.379144 ' Size:' 17521943
'# File Load+Run: ' 'test.out2' ' Time: ' 0.95122 ' Size:' 17519371
'# File Load+Run: ' 'test.out3' ' Time: ' 2.954594 ' Size:' 18333035
'# File Load+Run: ' 'test.out4' ' Time: ' 7.236041 ' Size:' 18327247
Oddly the first file is faster in bytecode (which is what I expected for all of them).
Can this be clearly explained? I have searched in many places (here specifically) and could not find any similar discussions (let me know if there are - please).