In the office, with the Lua environment, I decided to give a try on the Lua running speed. The measurement method is the same as Squirrel, and the C code reading the TSC register is encapsulated into a method, in Lua and Squirrel, I was surprised by the test results. Lua is actually slower Than Squirrel.
Lua Table:
Tb = {};
I = 0;
While (I <1000)
Do
Tb [I] = I * 13
I = I + 1;
End
Total = 0;
I = 0;
While (I <1000)
Do
Total = total + tb [I];
I = I + 1;
End
This program is similar to the Squirrel test program. Lua spends 20% K of CPU pulse on executing this code, and Squirrel is almost faster than Lua. I don't want to come to the conclusion that Squirrel is faster than Lua. Does Lua scan, analyze, and execute code? Squirrel has actually pre-compiled before executing the code, and the script file has become the mainland bytecode stored in Squirrel Virtual Machine. If Lua does not adopt and compile the technology, it is understandable that it lags behind Squirrel.
I did not develop games. I only know the basic usage of Lua. If you have a Lua master, you can help me check whether the Lua virtual machine has a pre-compilation process. If not, lua can fully pre-compile like Squirrel to improve execution speed.