bench-fps
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

bench-fps

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

npm i bench-fps pnpm add bench-fps yarn add bench-fps

Examples

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

API

# AggregateStats src/.fastpm/-/everyday-math@0.0.1/dist/types/everyday-math.d.ts#L21
# FPSCounter src/bench-fps.ts#L6

# stop src/bench-fps.ts#L11

    # ()

      ()  =>

        number []

# Stats src/.fastpm/-/everyday-math@0.0.1/dist/types/everyday-math.d.ts#L14
# benchFPS(times, iterationDuration, fn) src/bench-fps.ts#L51

    # times

      number

    # iterationDuration

      number

    # fn(frame, time)

      # frame

        number

      # time

        number

      fn(frame, time)  =>

        void

benchFPS(times, iterationDuration, fn)  =>

# fpsCounter() src/bench-fps.ts#L17

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

Readme

Keywords

none

Package Sidebar

Install

npm i bench-fps

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

84 kB

Total Files

18

Last publish

Collaborators

  • stagas