-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.bench.ts
More file actions
38 lines (34 loc) · 742 Bytes
/
Copy pathindex.bench.ts
File metadata and controls
38 lines (34 loc) · 742 Bytes
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
import { fc } from '@fast-check/vitest'
import { bench } from 'vitest'
import whichBuiltinType from 'which-builtin-type'
import builtinType from './index.ts'
const anythingArb = fc.anything({
withBoxedValues: true,
withSet: true,
withMap: true,
withObjectString: true,
withNullPrototype: true,
withBigInt: true,
withDate: true,
withTypedArray: true,
withSparseArray: true,
})
const values = fc.sample(anythingArb, { seed: 42, numRuns: 500 })
bench(
`whichBuiltinType`,
() => {
for (const value of values) {
whichBuiltinType(value)
}
},
{ warmupIterations: 75 },
)
bench(
`builtinType`,
() => {
for (const value of values) {
builtinType(value)
}
},
{ warmupIterations: 75 },
)