love.timer.getTime

love.timer.getTime

Returns the value of a timer with an unspecified starting time. This function should only be used to calculate differences between points in time, as the starting time of the timer is unknown.

Function

Synopsis

time = love.timer.getTime( )

Arguments

None.

Returns

number time
The time in seconds.

Examples

Checking how long something takes

local start = love.timer.getTime()
 
-- Concatenate "bar" 1000 times.
local foo = ""
for _ = 1, 1000 do
	foo = foo .. "bar"
end
 
-- Resulting time difference in seconds. Multiplying it by 1000 gives us the value in milliseconds.
local result = love.timer.getTime() - start
print( string.format( "It took %.3f milliseconds to concatenate 'bar' 1000 times!", result * 1000 ))

See Also


© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.timer.getTime

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部