lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Egor Skriptunoff <egor.skriptunoff@gmail.com>于2018年8月10日周五 上午3:38写道:
Let's benchmark modulo operator.
The code is here:  pastebin.com/13XBxdn6
The Lua executables are x64 exe-files built with VS2010.
 
The results:
 
   C:\>lua51.exe addition_benchmark.lua
   CPU seconds for floating point addition:        1.185
 
   C:\>lua52.exe addition_benchmark.lua
   CPU seconds for floating point addition:        1.093
 
   C:\>lua53.exe addition_benchmark.lua
   CPU seconds for integer addition:       1.107
   CPU seconds for floating point addition:        1.556
 
   C:\>lua54.exe addition_benchmark.lua
   CPU seconds for integer addition:       1.452
   CPU seconds for floating point addition:        1.717
 
Why numeric addition (the simplest thing in Lua) become slower starting with Lua 5.3?
Is it because of detecting operand subtypes (int/float) inside every "ADD" instruction?


Lua 5.4  optimize small constant integer ADD by OP_ADDI , and a bit slower for big constants.

You can change those big integers to small one and test again, you will find much faster.