1.0.0 • Published 3 years ago

bench-fps v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

FPS (frames per second) benchmark utility for perf testing.

Examples

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)
  })
})

API

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas