🚀 benchmark ?

This commit is contained in:
platane
2020-10-06 23:53:46 +02:00
committed by Platane
parent b0784fbaca
commit 16a47349be
10 changed files with 181 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
import { getAvailableInterestingRoutes } from "../getAvailableRoutes";
import { small as grid } from "../__fixtures__/grid";
import { snake3 } from "../__fixtures__/snake";
import { performance } from "perf_hooks";
import { getAvailableRoutes } from "../getAvailableRoutes2";
const m = 1000;
{
const s = performance.now();
for (let k = m; k--; ) {
const solutions = [];
getAvailableInterestingRoutes(
grid,
snake3,
(snakes) => {
solutions.push(snakes);
return false;
},
2
);
}
console.log((performance.now() - s) / m, "ms");
}
{
const s = performance.now();
for (let k = m; k--; ) {
getAvailableRoutes(grid, snake3, 2);
}
console.log((performance.now() - s) / m, "ms");
}