Add line table benchmark

This commit is contained in:
Jordan Pittman 2025-05-07 09:10:40 -04:00
parent 347d9e2971
commit f3fc8137f2

View file

@ -0,0 +1,13 @@
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { bench } from 'vitest'
import { createLineTable } from './line-table'
const currentFolder = fileURLToPath(new URL('..', import.meta.url))
const cssFile = readFileSync(currentFolder + '../preflight.css', 'utf-8')
const table = createLineTable(cssFile)
bench('line table lookups', () => {
for (let i = 0; i < cssFile.length; ++i) table.find(i)
})