Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by Joncom

Someone correct me if I'm wrong here, but it seems that the debug module clocks are not necessarily accurate. Or at least, not what you might expect.

This is due to the order of operations that occur when classes inject/extend to and from each other.

For example, the debug module injects a clock into ig.Game:

ig.Game.inject({
    draw: function() {
        ig.graph.beginClock('draw');
        this.parent();
        ig.graph.endClock('draw');
    }
});

However, since this module is always loaded before our custom game class (lib/game/main.js), that means any modifications to draw we make in our game class won't be clocked.

MyGame = ig.Game.extend({
    // ...
    
    // this draw function wraps after the debug version
    draw: function() {
        this.parent(); // will be clocked
        this.drawGUI(); // will NOT be clocked
    }
});

The same applies to the other clocks, such as the "update" clock. It's only measuring the vanilla game update function, which includes updateEntities and checkEntities for example, but none of your custom game code.

I guess this is more of a heads up to others, than an actual bug report.

8 years ago by dungeonmaster

I have the same observation although didn't dive deep much like you. Any extended update function of a game class is shown in the system lag and not in the update.

7 years ago by Fravio4

explained please about this function
draw: function() {
this.parent(); // will be clocked
this.drawGUI(); // will NOT be clocked
}

7 years ago by Joncom

Quote from Fravio4
explained please about this function
draw: function() {
this.parent(); // will be clocked
this.drawGUI(); // will NOT be clocked
}
Any vanilla Impact code taking place inside this.parent() will count toward the debug draw time in ms. However, any custom code that you write yourself inside of main.js will not be included in that time.

Let's say the debug module is reporting that your game takes 5 ms to draw each frame. Well, it may actually be more than that if you're drawing other stuff inside your draw function, because your code is excluded.
Page 1 of 1
« first « previous next › last »