FPS (frames per second) benchmark utility for perf testing.
npm i bench-fps
|
pnpm add bench-fps
|
yarn add bench-fps
|
# web
# view source
example/web.ts
import { benchFPS } from 'bench-fps'
describe('perf', () => {
it('wheeling', async () => {
const { aggregateStats: aggr } = await benchFPS(3, 4000, x => {
window.dispatchEvent(
new WheelEvent('wheel', {
deltaY: (Math.random() - 0.5) * Math.sin(x * Math.cos(x * 0.5) * 0.05)
* 250,
})
)
})
console.table(aggr)
expect(aggr.min).toBeGreaterThan(15)
expect(aggr.mean).toBeGreaterThan(58)
expect(aggr.meanStd).toBeLessThan(1.2)
})
})
# benchFPS
(times, iterationDuration, fn)
src/bench-fps.ts#L51 benchFPS(times, iterationDuration, fn) =>
-
Promise<{
}>
- everyday-math by stagas – Everyday math utilities.
- everyday-utils by stagas – Everyday utilities
All contributions are welcome!