Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/stagas/bench-fps
- Owner: stagas
- License: mit
- Created: 2022-08-19T05:21:24.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-19T07:09:29.000Z (about 2 years ago)
- Last Synced: 2024-10-19T11:11:22.764Z (26 days ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bench-fpsFPS (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 # animFrame
src/bench-fps.ts#L9
number
fps
src/bench-fps.ts#L7 number []
lastFrameTime
src/bench-fps.ts#L8 number
start
src/bench-fps.ts#L10 # ()
() =>
- void
stop
src/bench-fps.ts#L11 # ()
() =>
- number []
Stats
# benchFPS
(times, iterationDuration, fn) src/bench-fps.ts#L51 benchFPS(times, iterationDuration, fn) =>
Promise<{
# aggregateStats
= ...
src/bench-fps.ts#L84
stats
= allStats
src/bench-fps.ts#L83 Stats []
fpsCounter
() src/bench-fps.ts#L17
fpsCounter() =>
## 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)