# hbu

> How's by u? A performance analysis CLI

Latest version **0.3.5** (published 2020-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install hbu
pnpm add hbu
yarn add hbu
bun add hbu
```

Provides the command `hbu`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.5 |
| Published | 2020-04-28 |
| First published | 2019-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mac Heller-Ogden |
| Maintainers | machellerogden |
| Keywords | performance, analysis, cli |

## Links

- npm: https://www.npmjs.com/package/hbu
- Repository: https://github.com/machellerogden/hbu
- Homepage: https://github.com/machellerogden/hbu#readme
- Issues: https://github.com/machellerogden/hbu/issues
- npm.io page: https://npm.io/package/hbu

## Dependencies (4)

- [rc](https://npm.io/package/rc.md) ^1.2.8
- [glob](https://npm.io/package/glob.md) ^7.1.6
- [gc-stats](https://npm.io/package/gc-stats.md) ^1.4.0
- [markdown-table](https://npm.io/package/markdown-table.md) ^1.1.3

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.3.5 (latest) — 2020-04-28
- 0.3.4 — 2020-04-28
- 0.3.3 — 2019-04-02
- 0.3.2 — 2019-03-25
- 0.3.1 — 2019-03-15
- 0.3.0 — 2019-03-14
- 0.2.2 — 2019-03-14
- 0.2.1 — 2019-03-14
- 0.2.0 — 2019-03-14
- 0.1.0 — 2019-03-14
- 0.0.15 — 2019-03-13
- 0.0.14 — 2019-03-13
- 0.0.13 — 2019-03-13
- 0.0.12 — 2019-03-13
- 0.0.11 — 2019-03-13
- … 11 more at https://npm.io/package/hbu/versions

## README

# How's by u?

> Performance testing CLI

## Install

```
npm i -D hbu
```

...or, globally, if you must:

```
npm i -g hbu
```

## Example

There is a file called `basic.js` inside the `./example` directory which looks like this:

```
const { start, end, times } = require('hbu');

const data = {
    a: "a",
    b: "b",
    c: "c"
};

const leak = [];

let i = 0;

start();

while (i < times) {
    leak.push(JSON.parse(JSON.stringify(data)));
    i++;
}

end();
```

As shown, simply import `hbu` and use the given `start`, `end` and `times` exports to write your test scenario.

Run your test, like so:

```
$ hbu './example/basic.js' --times 1000000 --gc-stats
| Test Label   | Heap Used (MB) | Duration (MS) | GC Collected Heap (MB) | GC Pause Duration (MS) | GC Events (major) | GC Events (minor) |
| ------------ | -------------: | ------------: | ---------------------: | ---------------------: | ----------------: | ----------------: |
| example-test |          78.85 |    1427.17733 |                 193.02 |               86.24606 |                 2 |                25 |
```

*Notes:*

* Only write *one test per file.* Each test is run in an isolated child process by the test runner to make sure the performance of a given test isn't impacted by other tests.
* Report output is valid markdown! Use it in READMEs or tther documentation.

If you want to test something without requiring in hbu and manually adding `start` and `end` calls, you make do so as shown in the [./example/injected.js](./example/injected.js) example file.

## Usage

For the most part, it's as simple as writing and running your tests as shown in the examples above. Note that the `end` function can be called inside a callback or at the end of a promise-chain for async testing. Refer to options below for additional functionality.

## Options

### `--times`

This sets the `process.env.HBU_TIMES` environment variable and is also available as `hbu.time` when requiring the `hbu` module into your project.

### `--gc-stats`

Adds garbage collection statistics to the performance report.

### `--mode`

Value of `--mode` can be one of: `sequential` (default) or `parallel`. Running your tests in parallel mode is much faster but may be slightly less accurate as the concurrent processes compete for CPU and memory.

### `--inject`

When the `--inject` flag is included, your tests will be automatically instrumented without needing explicit calls `start` or `end`. Note that if you do have explicit calls to `start` or `end` in your code they will be ignore when this flag is used.

Note that performance metrics for tests run with the `--inject` flag will include load time and exit time of the file module. If you're looking to test a specific fragment of your file module, you should require `hbu` and manually add calls to `start` and `end` for the highest level of accuracy.

## License

MIT

---
_Source: https://npm.io/package/hbu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
