 class MainLoop
 
     constructor: (context)->
-        # All milliseconds
+        # All in milliseconds
         @frame_duration = 16
-        @last_frame_durations = [16, 16, 16, 16, 16, 16, 16, 16, 16, 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

        if not @enabled
            return
        @last_frame_durations[@_fdi] = frame_duration
        @_fdi = (@_fdi+1) % @last_frame_durations.length
        
        # Limit low speed of logic and physics
        frame_duration = Math.min(frame_duration, MAX_FRAME_DURATION)


            for p in scene.active_particle_systems
                p._eval()
        
        time2 = performance.now()

        for scene_name in @context.loaded_scenes
            if scene.physics_enabled and (scene.rigid_bodies.length or scene.kinematic_characters.length)
                get_last_char_phy scene.kinematic_characters
                step_world scene.world, frame_duration * 0.001
                phy_to_ob scene.rigid_bodies
        
        time3 = performance.now()

        evaluate_all_animations @context, frame_duration
        
        time4 = performance.now()

        for name, video_texture of @context.video_textures
            #TODO: Optimize updating only the video_textures whose video is being played
            video_texture.update_texture?()

        # for s in @context.active_sprites
        #     s.evaluate_sprite frame_duration
        @context.render_manager.draw_all()

        time5 = performance.now()

        for scene_name in @context.loaded_scenes
            scene = @context.scenes[scene_name]
