https://github.com/lmzdev/delta-counter
Count average events per second in a timespan.
https://github.com/lmzdev/delta-counter
nodejs npm
Last synced: 2 months ago
JSON representation
Count average events per second in a timespan.
- Host: GitHub
- URL: https://github.com/lmzdev/delta-counter
- Owner: lmzdev
- License: mit
- Created: 2023-01-06T16:22:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T12:43:55.000Z (over 2 years ago)
- Last Synced: 2025-03-02T01:28:13.698Z (3 months ago)
- Topics: nodejs, npm
- Language: TypeScript
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# delta-counter
[](https://github.com/lmzdev/delta-counter/actions/workflows/node.js.yml)Count average events per second in a timespan. Just like adding a tally counter to ```setInterval()```.
## Example/Concept
```js
import * as Mqtt from 'mqtt'
import { DeltaCounter } from 'delta-counter'const client = Mqtt.connect()
client.on('connect', () => {
client.subscribe('#')
}const intervalSec = 5
const dc = new DeltaCounter(intervalSec, (eventsPerSecond) => {
console.log("Average number of messages per second: "+eventsPerSecond)
}).start()client.on('message', () => dc.tick())
```