Timing Issue?



  • Using the following code:

    ... rest of headers and requires ...
    Memory.tLast = Game.time;
    module.exports.loop = function () {
        var cpuLoad = Game.cpu.getUsed();
        ... rest of code ...
        console.log("Load time: " + cpuLoad + " cpu. Run time: " + Math.round((Game.cpu.getUsed() - cpuLoad) * 1000000) / 1000000 + " cpu. " + (Game.time != Memory.tLast ? "A Global Reset occurred." : ""));
    }

    I logged this output:

    [7:05:19 AM]Load time: 0.170392 cpu. Run time: 5.025377 cpu. A Global Reset occurred.
    [7:05:22 AM]Load time: 0.136717 cpu. Run time: 5.887232 cpu. A Global Reset occurred.
    [7:05:25 AM]Load time: 5.744365 cpu. Run time: 6.176316 cpu.
    [7:05:27 AM]Load time: 6.422471 cpu. Run time: 6.321166 cpu.
    [7:05:32 AM]Load time: 0.144935 cpu. Run time: 5.409094 cpu. A Global Reset occurred.
    [7:05:35 AM]Load time: 6.272357 cpu. Run time: 5.873283 cpu.
    [7:05:37 AM]Load time: 6.680127 cpu. Run time: 5.771699 cpu.
    [7:05:40 AM]Load time: 5.27978 cpu. Run time: 11.591988 cpu.
    [7:05:42 AM]Load time: 3.096351 cpu. Run time: 4.826359 cpu.
    [7:05:46 AM]Load time: 1.673431 cpu. Run time: 7.957285 cpu. A Global Reset occurred.
    [7:05:49 AM]Load time: 0.128746 cpu. Run time: 9.453756 cpu. A Global Reset occurred.
    [7:05:52 AM]Load time: 2.77776 cpu. Run time: 4.721952 cpu.
    [7:05:54 AM]Load time: 0.180163 cpu. Run time: 6.637582 cpu. A Global Reset occurred.
    [7:05:57 AM]Load time: 0.143734 cpu. Run time: 10.472935 cpu. A Global Reset occurred.
    [7:06:03 AM]Load time: 0.11747 cpu. Run time: 5.502456 cpu. A Global Reset occurred.
    [7:06:06 AM]Load time: 3.273769 cpu. Run time: 8.800834 cpu.
    [7:06:08 AM]Load time: 0.134438 cpu. Run time: 7.556341 cpu. A Global Reset occurred.
    [7:06:11 AM]Load time: 0.125522 cpu. Run time: 7.220895 cpu. A Global Reset occurred.
    [7:06:14 AM]Load time: 1.039441 cpu. Run time: 6.039298 cpu. A Global Reset occurred.
    [7:06:17 AM]Load time: 0.118541 cpu. Run time: 5.394288 cpu. A Global Reset occurred.
    [7:06:20 AM]Load time: 0.11541 cpu. Run time: 4.587587 cpu. A Global Reset occurred.

    Notice the low load time when a global reset occurs, and a high load time when one doesn't... in other words, I'm charged for more CPU when less code runs! Perhaps this is the part of the cause of the recent reports if inaccurate CPU limits?