Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stagas committed Nov 13, 2021
1 parent a1ca7fe commit c004c21
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 4 deletions.
117 changes: 116 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,116 @@
# benny-vipu
<h1 align="center">benny-vipu</h1>

<p align="center">
run <a href="https://github.com/caderek/benny">benny</a> benchmarks in the browser headless using <a href="https://github.com/stagas/vipu">vipu</a>
</p>

<p align="center">
<a href="#install"> 🔧 <strong>Install</strong></a>
· <a href="#example"> 🧩 <strong>Example</strong></a>
· <a href="#api"> 📜 <strong>API docs</strong></a>
· <a href="https://github.com/stagas/benny-vipu/releases"> 🔥 <strong>Releases</strong></a>
· <a href="#contribute"> 💪🏼 <strong>Contribute</strong></a>
· <a href="https://github.com/stagas/benny-vipu/issues"> 🖐️ <strong>Help</strong></a>
</p>

***

## Install

```sh
$ npm i benny-vipu -g
```

## CLI

Usage: benny-vipu [options] <file>

<file> Benchmark filename to run

-c, --clear Clear screen between page reloads
-f, --force Force cache renewal
-d, --debug Print debug information
--min=n Minimum iteration samples (default: 3)
--max=n Maximum time in seconds (default: 1)

## Example

```ts
import { suite, add, finish } from 'benny-vipu'

const container = document.body

const clear = () => (container.innerHTML = '')

const bench = async () => {
for (const count of [100, 1_000, 10_000]) {
await suite(
`insert ${count} elements`,

add('createElement/appendChild', () => {
clear()
for (let i = 0; i < count; i++) {
const div = document.createElement('div')
container.appendChild(div)
}
}),

add('html+=div + innerHTML', () => {
clear()
let html = ''
for (let i = 0; i < count; i++) {
html += '<div></div>'
}
container.innerHTML = html
}),

add('Array.fill.join() + innerHTML', () => {
clear()
container.innerHTML = Array(count).fill('<div></div>').join('')
}),
)
}
}

bench().then(finish)
```

<img src="demo.png">

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

* [run](#run)
* [Parameters](#parameters)

### run

[src/index.ts:46-86](https://github.com/stagas/benny-vipu/blob/a1ca7fe73f1c5f952c7624c5c10560d5ea7316aa/src/index.ts#L46-L86 "Source code on GitHub")

Runs a given benchmark file.

#### Parameters

* `filename` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The benchmark filename
* `options` **Options** (optional, default `new Options()`)

* `options.clear` Clear screen between page reloads
* `options.force` Force cache renewal
* `options.debug` Print debug information
* `options.minSamples` Minimum iteration samples (default: 3)
* `options.maxTime` Maximum time in seconds (default: 1)

## Contribute

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

All contributions are welcome!

## License

MIT © 2021
[stagas](https://github.com/stagas)
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "stagas",
"short": "stagas/benny-vipu",
"description": "run benny benchmarks in the browser headless using vipu",
"version": "0.0.0",
"version": "1.0.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit c004c21

Please sign in to comment.