From f3fc8137f25a3e7430e4d50e7530f0bc1d4ded91 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 7 May 2025 09:10:40 -0400 Subject: [PATCH] Add line table benchmark --- .../tailwindcss/src/source-maps/line-table.bench.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 packages/tailwindcss/src/source-maps/line-table.bench.ts diff --git a/packages/tailwindcss/src/source-maps/line-table.bench.ts b/packages/tailwindcss/src/source-maps/line-table.bench.ts new file mode 100644 index 000000000..862e2d398 --- /dev/null +++ b/packages/tailwindcss/src/source-maps/line-table.bench.ts @@ -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) +})