Open History to see the last commit
1import { bench, describe } from 'vitest'
2import { hash } from '../src/hashing/hash'
3
4const cached = { id: 1, title: `row`, active: true }
5hash(cached)
6let result = 0
7
8describe(`hash input paths`, () => {
9 bench(`primitive`, () => {
10 result ^= hash(42)
11 })
12 bench(`cached row`, () => {
13 result ^= hash(cached)
14 })
15 bench(`fresh row`, () => {
16 result ^= hash({ id: 1, title: `row`, active: true })
17 })
18})
19
20// Keep benchmark results observable without adding work inside each sample.
21export function getHashBenchmarkResult(): number {
22 return result
23}