Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stagas/bench-fps

FPS (frames per second) benchmark utility for perf testing.
https://github.com/stagas/bench-fps

Last synced: 14 days ago
JSON representation

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

Awesome Lists containing this project

README

        


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

    ```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.sin(x * 0.3) * 120 ** 1.2,
    })
    )
    })

    console.table(aggr)

    expect(aggr.min).toBeGreaterThan(15)
    expect(aggr.mean).toBeGreaterThan(58)
    expect(aggr.meanStd).toBeLessThan(1.2)
    })
    })
    ```


## API

# AggregateStats

    # max


      number

    # maxStd

      number

    # mean

      number

    # meanStd

      number

    # median

      number

    # medianStd

      number

    # min

      number

    # minStd

      number


# FPSCounter src/bench-fps.ts#L6

# stop src/bench-fps.ts#L11

    # ()


      ()  =>


        number []

# Stats

    # max


      number

    # mean

      number

    # median

      number

    # min

      number

    # std

      number


# 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

- [everyday-math](https://npmjs.org/package/everyday-math) by [stagas](https://github.com/stagas) – Everyday math utilities.
- [everyday-utils](https://npmjs.org/package/everyday-utils) by [stagas](https://github.com/stagas) – Everyday utilities

## Contributing

[Fork](https://github.com/stagas/bench-fps/fork) or [edit](https://github.dev/stagas/bench-fps) and submit a PR.

All contributions are welcome!

## License

MIT © 2022 [stagas](https://github.com/stagas)