Difference between revisions of "love.timer.getTime"

m (1 revision: Importing from potato (again).)
(Added example.)
Line 1: Line 1:
 
 
Returns the amount of time since some time in the past.  
 
Returns the amount of time since some time in the past.  
 
This function should only be used to calculate differences between points in time, so exactly when this ''some time'' is should not matter.
 
This function should only be used to calculate differences between points in time, so exactly when this ''some time'' is should not matter.
Line 11: Line 10:
 
=== Returns ===
 
=== Returns ===
 
{{param|number|time|The time in seconds.}}
 
{{param|number|time|The time in seconds.}}
 +
== Examples ==
 +
=== Checking how long something takes ===
 +
<source lang="lua">
 +
foo = ""
 +
stime = love.time.getTime()
 +
 +
for i=1,1000 do
 +
foo = foo .. "bar"
 +
end
 +
 +
etime = love.time.getTime()
 +
print("It took " .. (etime-stime) .. " to concatenate 'bar' 1000 times!")
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love.timer]]
 
* [[parent::love.timer]]

Revision as of 17:13, 26 February 2010

Returns the amount of time since some time in the past. This function should only be used to calculate differences between points in time, so exactly when this some time is should not matter.

Function

Synopsis

time = love.timer.getTime( )

Arguments

None.

Returns

number time
The time in seconds.

Examples

Checking how long something takes

foo = ""
stime = love.time.getTime()

for i=1,1000 do
	foo = foo .. "bar"
end

etime = love.time.getTime()
print("It took " .. (etime-stime) .. " to concatenate 'bar' 1000 times!")

See Also