https://github.com/theprofs/recordable
A plottable histogram
https://github.com/theprofs/recordable
nodejs performance-testing testing
Last synced: 3 months ago
JSON representation
A plottable histogram
- Host: GitHub
- URL: https://github.com/theprofs/recordable
- Owner: TheProfs
- License: other
- Created: 2024-07-22T12:20:23.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T04:33:15.000Z (11 months ago)
- Last Synced: 2025-03-11T01:48:34.110Z (3 months ago)
- Topics: nodejs, performance-testing, testing
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[![test-workflow][test-badge]][test-workflow] [![codeql-workflow][codeql-badge]][codeql-workflow]
# :watch: recordable
> recordable & plottable [histogram][histogram]
## Install
```bash
npm i https://github.com/TheProfs/recordable.git
```## Usage
### Basic
```js
import { Recordable } from 'recordable'const histogram = new Recordable()
for (let i = 0; i < 600; i++)
histogram.record(Math.round(Math.random() * 20) + 1)console.log(histogram.count)
// count of invocations
// 600console.log(histogram.min)
// minimum recorded value
// 3.05 msconsole.log(histogram.max)
// maximum recorded value
// 85.17 mconsole.log(histogram.mean)
// Arithmetic mean/average
// 11.42 msconsole.log(histogram.stddev)
// statistical standard deviation between all values
// 5.17 ms
```### Available methods
`histogram.record(value)`
record a value
`histogram.tick()`
record a value of `1`
`histogram.recordDelta(label)`
record the [time-delta (Δt)][delta] between invocations with the same `label`
value.\
Can be called without a `label` parameter, in which case it records the
`time-delta` since the last invocation without a label parameter.`histogram.reset()`
does exactly what you think it does
`histogram.plot()`
produce an ASCII plot of the `mean` of all values.\
See below.### Plotting
```js
import { Recordable } from 'recordable'const histogram = new Recordable()
for (let i = 0; i < 600; i++)
histogram.record(Math.round(Math.random() * 20) + 1)histogram.plot()
``````console
24.33 ┤╭╮
23.27 ┤││
22.21 ┤││
21.15 ┤││
20.09 ┤││
19.03 ┤││
17.97 ┤││ ╭
16.91 ┤││ ╭╮│
15.85 ┤││ ╭╮ ╭╮ ╭╮ ╭╮ │││
14.79 ┤││ ╭╮ ╭╮ ╭╮ ││ ││ ╭╮ ││╭╮ ││ ╭╮ │││
13.73 ┤││ ││ ││ ││ ││ ╭╮ ││╭╮ ││ ││││ ╭╮ ╭╮ ││ ╭╮ ││ ╭╮│╰╯
12.67 ┤│╰╮│╰─╯│ ╭╯│ ╭─╮ ╭─╮ │╰╮ ╭╮ ││ ││││╭─╮ │╰╮ ││││╭╮╭╮ ││ │╰╮│╰╮ ││ ╭╯│ │││
11.61 ┤│ ││ │ ╭╯ ╰╮│ ╰╮│ │ │ │ ││ ╭╮ ╭╯│ │││╰╯ │ │ │ ╭╮ ╭╮╭╮ │││││╰╯│╭╯│╭╯ ││ │ ╭╮ ││╭╯ ╰╮│││
10.55 ┤│ ││ ╰╮│ ││ ││ │╭╯ │╭╮││╭╮ ╭─╯│ │ ╰╮│││ ╰─╮│ │╭╯│ │││╰╮│││││ ││ ││ ╰╯ │ ││╭╯││ ╰╯││
9.48 ┤│ ╰╯ ││ ╰╯ ╰╯ ╰╯ ││││╰╯╰─╯ │ │ ││││ ││ ╰╯ ╰╮╭──╯╰╯ ││││╰╯ ╰╯ ││ │ │╰╯ ╰╯ ╰╯
8.42 ┤│ ╰╯ ╰╯╰╯ │ │ ││││ ╰╯ ││ ││││ ││ ╰─╮│
7.36 ┤│ ╰─╯ ╰╯╰╯ ╰╯ ╰╯││ ││ ││
6.30 ┤│ ╰╯ ╰╯ ╰╯
5.24 ┤│
4.18 ┤│
3.12 ┤│
2.06 ┤│
1.00 ┼╯
Nicholass-MacBook-Air:recordable nicholaswmin$```
## Tests
Install deps
```bash
npm ci
```Run unit tests
```bash
npm test
```Run test coverage
```bash
npm run test:coverage
```## Authors
- [@Bitpaper][profs]
- [@nicholaswmin][nicholaswmin]## License
[MIT-0 "No Attribution" License][license]
[test-badge]: https://github.com/TheProfs/recordable/actions/workflows/test:unit.yml/badge.svg
[test-workflow]: https://github.com/TheProfs/recordable/actions/workflows/test:unit.yml[codeql-badge]: https://github.com/TheProfs/recordable/actions/workflows/codeql.yml/badge.svg
[codeql-workflow]: https://github.com/TheProfs/recordable/actions/workflows/codeql.yml[histogram]: https://en.wikipedia.org/wiki/Histogram
[delta]: https://en.wikipedia.org/wiki/Delta_timing
[mean]: https://en.wikipedia.org/wiki/Mean
[stddev]: https://en.wikipedia.org/wiki/Standard_deviation
[profs]: https://github.com/TheProfs
[nicholaswmin]: https://github.com/nicholaswmin
[license]: ./LICENSE