Lua - Current time in milliseconds

后端 未结 10 950
自闭症患者
自闭症患者 2020-12-01 01:56

Is there a common way to get the current time in or with milliseconds?

There is os.time(), but it only provides full seconds.

10条回答
  •  [愿得一人]
    2020-12-01 02:15

    If you want to benchmark, you can use os.clock as shown by the doc:

    local x = os.clock()
    local s = 0
    for i=1,100000 do s = s + i end
    print(string.format("elapsed time: %.2f\n", os.clock() - x))
    

提交回复
热议问题