-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.ts
More file actions
41 lines (32 loc) · 1.08 KB
/
bench.ts
File metadata and controls
41 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as fs from 'node:fs'
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function runBenchmarks() {
const args = process.argv.slice(2)
const filter = args[0]
const files = fs.readdirSync(__dirname).filter((file) => {
const isBenchFile = file.endsWith('.ts') && file !== 'bench.ts' && !file.endsWith('.d.ts')
if (!isBenchFile) return false
if (filter) {
return file.toLowerCase().includes(filter.toLowerCase())
}
return true
})
if (files.length === 0) {
console.log(`No benchmark files found matching filter "${filter}"`)
return
}
console.log(`Found ${files.length} benchmark files to run...`)
for (const file of files) {
console.log(`\n========================================`)
console.log(`Running benchmark: ${file}`)
console.log(`========================================`)
try {
await import(path.join(__dirname, file))
} catch (e) {
console.error(`Error running ${file}:`, e)
}
}
}
runBenchmarks()