Created
July 5, 2016 01:27
-
-
Save sscholl/ac741616d7257d902bb8a3a3779e1847 to your computer and use it in GitHub Desktop.
Game.cpu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.loop = function() { | |
if (Game.cpu.tickLimit < 500) { | |
console.log("Execution of loop is not possible, because tick limit is " + Game.cpu.tickLimit + "<500"); | |
return; | |
} | |
var time = Game.cpu.getUsed(); | |
console.log("--> LOAD TIME " + time); | |
console.log(" Game.cpu.limit " + Game.cpu.limit); | |
console.log(" Game.cpu.tickLimit " + Game.cpu.tickLimit); | |
console.log(" Game.cpu.bucket " + Game.cpu.bucket); | |
for (var roomName in Game.rooms) { | |
var room = Game.rooms[roomName]; | |
// do someething time consuming | |
var spawn = room.find(FIND_MY_SPAWNS)[0]; | |
for (var i = 0; i < 2; ++i) room.findPath(spawn.pos.findClosestByRange(FIND_SOURCES).pos, spawn.pos); | |
} | |
console.log("<-- MAIN TIME " + (Game.cpu.getUsed() - time)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment