         @context.events.reset_frame_events()
         @frame_number += 1
 
+        time6 = performance.now()
+
+        @logic_durations[@_fdi] = (time2 - time) + (time6 - time5)
+        @physics_durations[@_fdi] = time3 - time2
+        @animation_durations[@_fdi] = time4 - time3
+        @render_durations[@_fdi] = time5 - time4
+        @_fdi = (@_fdi+1) % @last_frame_durations.length
+        if @_fdi == 0 and @update_fps
+            @update_fps(@)
+
+
 module.exports = {MainLoop}

        @_bound_run = @run.bind @
        @_frame_callbacks = []
        @frame_number = 0

    run: ->
        @stopped = false

class MainLoop

    constructor: (context)->
        # All in milliseconds
        @frame_duration = 16
        # Time from beginning of a tick to the next (including idle time)
        @last_frame_durations = (new Float32Array(30)).fill(16)
        # Time it takes for running (logic) JS code
        @logic_durations = (new Float32Array(30)).fill(16)
        # Time it takes for physics evaluations
        @physics_durations = (new Float32Array(30)).fill(16)
        # Time it takes for evaluating animations and constraints
        @animation_durations = (new Float32Array(30)).fill(16)
        # Time it takes for submitting GL commands
        @render_durations = (new Float32Array(30)).fill(16)
        @_fdi = 0
        @timeout_time = context.MYOU_PARAMS.timeout
        @tasks_per_tick = context.MYOU_PARAMS.tasks_per_tick || 1
