GetElapsedTime

Definition

double GetElapsedTime()

Description

This function returns the elapsed time from the previous frame to the current frame in seconds.

Return Value

Elapsed time from the previous frame to the current frame in seconds

Example 1

elapsedTime = 0.0

function Init()

end

function Update()
    elapsedTime = GetElapsedTime()

    message = string.format("\nElapsed time is > %.2f" , elapsedTime )
    PrintConsole(message)
end
The result on my system is:


1598> Elapsed time is > 0.03
1599> Elapsed time is > 0.02
1600> Elapsed time is > 0.02
1601> Elapsed time is > 0.02
1602> Elapsed time is > 0.02
1603> Elapsed time is > 0.02
1604> Elapsed time is > 0.02
1605> Elapsed time is > 0.01
1606> Elapsed time is > 0.02
1607> Elapsed time is > 0.02
1608> Elapsed time is > 0.02
1609> Elapsed time is > 0.01
1610> Elapsed time is > 0.02
1611> Elapsed time is > 0.02
1612> Elapsed time is > 0.01
1613> Elapsed time is > 0.02
1614> Elapsed time is > 0.01
1615> Elapsed time is > 0.02
1616> Elapsed time is > 0.02
1617> Elapsed time is > 0.02
1618> Elapsed time is > 0.02
1619> Elapsed time is > 0.02
1620> Elapsed time is > 0.02
1621> Elapsed time is > 0.02
1622> Elapsed time is > 0.02
1623> Elapsed time is > 0.02
1624> Elapsed time is > 0.01
1625> Elapsed time is > 0.01
1626> Elapsed time is > 0.01

Example 2

elapsedSeconds = 0.0

function Init()

end

function Update()
    elapsedSeconds = elapsedSeconds + GetElapsedTime()

    message = string.format("\nElapsed seconds is > %.2f" , elapsedSeconds )
    PrintConsole(message)
end
The result on my system is:


1275> Elapsed seconds is > 0.03
1276> Elapsed seconds is > 0.04
1277> Elapsed seconds is > 0.05
1278> Elapsed seconds is > 0.07
1279> Elapsed seconds is > 0.08
1280> Elapsed seconds is > 0.10
1281> Elapsed seconds is > 0.12
1282> Elapsed seconds is > 0.13
1283> Elapsed seconds is > 0.15
1284> Elapsed seconds is > 0.16
1285> Elapsed seconds is > 0.18
1286> Elapsed seconds is > 0.19
1287> Elapsed seconds is > 0.21
1288> Elapsed seconds is > 0.22
1289> Elapsed seconds is > 0.24
1290> Elapsed seconds is > 0.25
1291> Elapsed seconds is > 0.27
1292> Elapsed seconds is > 0.29
1293> Elapsed seconds is > 0.30

 

 

adminGetElapsedTime