Module
love.timer
The timer module keeps track of time between frames, so that game objects can be updated in a FPS-independet fashion. The precision of the timer is usually 1ms, although this may vary from system to system. Hardware timers with higher precision are planned, but not implemented at the time of writing.
Functions
getFPS( ) Gets the current FPS.
getDelta( ) ret the current timestep.
sleep( ms ) Delays exection for an amount of time.
getTime( ) Gets approximate time since startup.
Examples
Example 7: Sleeping
  1. -- Example: Sleeping 
  2.  
  3. function update(dt) 
  4.     -- Sleeps 10ms after each udpate. By doing this, 
  5.     -- CPU time is made available for other processes, 
  6.     -- and your OS will love you for it. 
  7.     love.timer.sleep(10
  8. end 
Example 9: Timing code
  1. -- Example: Timing code 
  2.  
  3. function load() 
  4.     -- Get time before the code to be timed. 
  5.     t_start = love.timer.getTime() 
  6.      
  7.     -- Load 10 fonts. 
  8.     for i=12,22 do 
  9.         local f = love.graphics.newFont(love.default_font, i) 
  10.         love.graphics.setFont(f) 
  11.     end 
  12.      
  13.     -- Get time after. 
  14.     t_end = love.timer.getTime() 
  15.      
  16. end 
  17.  
  18. function draw() 
  19.     love.graphics.draw("Spent " .. (t_end-t_start) .. " seconds loading 10 fonts."5050
  20. end 
Copyright © 2006-2008 LÖVE Development Team.