^^ I've just updated it to allow for registering of any functions that you want. Useful to those that don't utilize the global prototypes the same way that I do.
Hatyr
@Hatyr
Posts made by Hatyr
-
RE: I made a thing.
-
Fix require times.
I've been doing a lot of work to bring down my CPU usage, but I can't seem to catch a break from the time it takes to load up my script. I've been getting a wide range of CPU limit notifications (anywhere from 0 to thousands of notifications per hour).
After putting in a ton of time optimizing my script, and working with my profiler, I don't know that there is anything I can do.
Below is my current main.js.
require('perf');
require('creep');
require('source');
require('spawns');
require('structures');
require('room-position');
var profiler = require('profiler');
profiler.enable();
module.exports.loop = function() {
profiler.wrap(function() {
var start = Game.getUsedCpu();
var index = 0;
for (var roomName in Game.rooms) {
index++;
if (index === 1 || Game.cpuLimit > 60) {
Game.rooms[roomName].work();
}
}
console.log(Game.getUsedCpu() - start, start);
});
} -
RE: Profiling
Piggy backing on this, I just released my profiler as OS. https://github.com/gdborton/screeps-profiler
-
RE: Best performance practice while using modules
I've found that each require call takes an amount of time correlated to how much the file contains... Following neomatrix's testing I created a bundle containing all my code then measured it's require time in main.js... 23 ms.
-
RE: High CPU usage differences on a tiny script
Delete is a fairly expensive operation, but I think the spikes are probably from require statements. Currently there doesn't seem to be a way around this, as in-lining all the code also makes the CPU spike.
The only solace is that when using `module.exports.loop` your require statements aren't always run.
-
RE: Inconsistencies in Memory Loading
I'm running into this now too...
-
RE: Need help with this code for performance issue
I'm sure you've figured this out by now, but moving takes a static .2 CPU time (the .3 is a little concerning). The larger 13 is probably due to pathfinding. As the previous poster said you could either roll your own path finder (although I believe it is faster now), or cache the results somehow.
-
RE: Now you can play Screeps without writing a single line of code!
@dexnode it isn't pointless... the downside to scripting is that your script can have flaws or situations that you didn't expect. If you're at your computer you can adjust for some minor flaws in your or someone else's script.
-
I made a thing.
I just open sourced a profiler that I made for Screeps to help keep my CPU usage lower. Hopefully I'm not the only one who will find it useful.