timers.SplitTime

( Brutus2D ??? )

timers.SplitTime() - returns the elapsed time since last call

Description

t = timers.SplitTime( index )

  • index - the index of the timer
  • t - time elapsed since last call

timers.SplitTime() returns the time elapsed since timers.SplitTime() was last called. This can be used to measure how much time it takes to render each frame, i.e. how much time each loopin takes. The time is returned in seconds. index is the index of the timer as returned by timers.Create().

Examples

This example shows how long it takes to draw 100 lines on the screen each frame.

graphics.Initialize
key.Initialize

Dim font
font = graphics.CreateFont ( "system", 10 )

Dim t
t = timers.Create()

Do
    graphics.Clear

    Dim i
    For i = 1 To 100
        graphics.SetLine 320, 240, rnd*640, rnd*480, argb(150, rnd*255, rnd*255, rnd*255)
    Next
    graphics.SetRect 10, 10, 120, 16, &hFF000000
    graphics.SetText "Frame time: " & timers.SplitTime(t), 10, 10, font
    graphics.Display
Loop Until key.Pressed ( vk_escape ) Or key.Pressed ( vk_windowx )

key.terminate
graphics.terminate

Related Pages

page tags: time timing
page_revision: 1, last_edited: 1214669885|%e %b %Y, %H:%M %Z (%O ago)