import fs from 'fs-extra'; import { parse } from 'yaml'; import { Bench } from 'tinybench'; import assert from 'assert'; import { solution_1 } from './part1.js'; import { solution_2 } from './part2.js'; const input = fs.readFileSync('./input',{ encoding: 'utf8'}); const solutions = parse( fs.readFileSync('./solutions.yml',{encoding:'utf8'})); const bench = new Bench({time: 10000}); bench.add( '1', () => { assert.equal(solution_1(input),solutions[1]) }) .add( '2', () => { assert.equal(solution_2(input),solutions[2]) }); await bench.run(); bench.tasks.forEach( ({result,name}) => { console.log(JSON.stringify({ day : 1, year : 2023, language: 'javascript', part: name, timestamp: new Date().toISOString(), time: result.mean / 1000 })); })