Added Logging Options to Improve Performance (#529)

* Added Logging Options to Improve Performance

* Requested Changes

Co-authored-by: Onyx Azryn <brycekabat@onyxazryn.com>
This commit is contained in:
Bryce Kabat 2020-10-21 17:32:57 -05:00 committed by GitHub
parent e480c1c8e5
commit f4efedcf9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 192 additions and 186 deletions

View file

@ -5,7 +5,7 @@
}(this, (function () {'use strict';
const getRoads = function() {
console.time("generateMainRoads");
TIME && console.time("generateMainRoads");
const cells = pack.cells, burgs = pack.burgs.filter(b => b.i && !b.removed);
const capitals = burgs.filter(b => b.capital);
if (capitals.length < 2) return []; // not enough capitals to build main roads
@ -21,12 +21,12 @@
}
cells.i.forEach(i => cells.s[i] += cells.road[i] / 2); // add roads to suitability score
console.timeEnd("generateMainRoads");
TIME && console.timeEnd("generateMainRoads");
return paths;
}
const getTrails = function() {
console.time("generateTrails");
TIME && console.time("generateTrails");
const cells = pack.cells, burgs = pack.burgs.filter(b => b.i && !b.removed);
if (burgs.length < 2) return []; // not enough burgs to build trails
@ -55,12 +55,12 @@
});
}
console.timeEnd("generateTrails");
TIME && console.timeEnd("generateTrails");
return paths;
}
const getSearoutes = function() {
console.time("generateSearoutes");
TIME && console.time("generateSearoutes");
const allPorts = pack.burgs.filter(b => b.port > 0 && !b.removed);
if (allPorts.length < 2) return [];
@ -93,12 +93,12 @@
});
console.timeEnd("generateSearoutes");
TIME && console.timeEnd("generateSearoutes");
return paths;
}
const draw = function(main, small, ocean) {
console.time("drawRoutes");
TIME && console.time("drawRoutes");
const cells = pack.cells, burgs = pack.burgs;
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
@ -133,7 +133,7 @@
return [x, y];
})), 1));
console.timeEnd("drawRoutes");
TIME && console.timeEnd("drawRoutes");
}
const regenerate = function() {