lua-users home
lua-l archive

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


2018-03-17 15:06 GMT-03:00 Tony Papadimitriou <tonypdmtr@gmail.com>:
On the other hand, why does this "a=os.time() for i=1,1000000000 do end print(os.time()-a)" run much slower on 5.4 compared to 5.3?

Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
a=os.time() for i=1,1000000000 do end print(os.time()-a)
9

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
a=os.time() for i=1,1000000000 do end print(os.time()-a)
14


I can't reproduce it!

For my machine

##### BEGIN #####
-- teste_time.lua
a=os.time() for i=1,1000000000 do end print(os.time()-a)
##### END ######

ROUND 1

-----------------------

time lua5.2 teste_time.lua
4

real    0m3.675s
user    0m3.675s
sys    0m0.000s

------------------------

time lua5.3 teste_time.lua
4

real    0m3.630s
user    0m3.612s
sys    0m0.004s

------------------------

time ./lua5.4 teste_time.lua
3

real    0m3.022s
user    0m2.996s
sys    0m0.016s

ROUND 2

----------------------------------------


Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> a=os.time() for i=1,1000000000 do end print(os.time()-a)
3
> os.exit()

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> a=os.time() for i=1,1000000000 do end print(os.time()-a)
3
> os.exit()

-----------------------------------

Conclusion: lua5.4 is faster, even doing a pointless loop.

--
Rodrigo Azevedo Moreira da Silva