🚀 gif creator benchmark

This commit is contained in:
platane
2020-10-09 12:43:25 +02:00
parent bc18120a98
commit 202bd7cacb
4 changed files with 67 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import { createGif } from "..";
import { getBestRoute } from "@snk/compute/getBestRoute";
import * as grids from "@snk/compute/__fixtures__/grid";
import { snake3 as snake } from "@snk/compute/__fixtures__/snake";
import { createSnake, nextSnake } from "@snk/compute/snake";
jest.setTimeout(20 * 1000);
@@ -44,3 +45,25 @@ for (const key of [
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
});
it(`should generate swipper`, async () => {
const grid = grids.smallFull;
let snk = createSnake(Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 })));
const chain = [snk];
for (let y = -1; y < grid.height; y++) {
snk = nextSnake(snk, 0, 1);
chain.push(snk);
for (let x = grid.width - 1; x--; ) {
snk = nextSnake(snk, (y + 100) % 2 ? 1 : -1, 0);
chain.push(snk);
}
}
const gif = await createGif(grid, chain, drawOptions, gifOptions);
expect(gif).toBeDefined();
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
});