bench-chain

2019-05-27 admin

bench-chain是什么

什么是bench-chain,benchmark recording - averages & graphs.

bench-chain使用教程帮助文档

<g-emoji class=“g-emoji” alias=“weight_lifting_man” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f3cb.png”>🏋️</g-emoji><g-emoji class=“g-emoji” alias=“chains” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/26d3.png”>⛓</g-emoji> bench-chain

chainable benchmark recording - averages & graphs.

Build Status NPM version MIT License bench-chain Dependencies fluents

screen shot 2017-04-24 at 5 51 21 am

extension of benchmark.js

<g-emoji class=“g-emoji” alias=“package” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f4e6.png”>📦</g-emoji> install

yarn add bench-chain
npm i bench-chain --save
const Bench = require('bench-chain')

<g-emoji class=“g-emoji” alias=“globe_with_meridians” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f310.png”>🌐</g-emoji> documentation

<g-emoji class=“g-emoji” alias=“microscope” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f52c.png”>🔬</g-emoji> tests

<g-emoji class=“g-emoji” alias=“blue_book” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f4d8.png”>📘</g-emoji> examples

<g-emoji class=“g-emoji” alias=“wave” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f44b.png”>👋</g-emoji> basic

const Bench = require('bench-chain')

Bench
  // location to store benchmarks
  .init(__dirname, 'basic.json')
  // tag current benchmarks with, to mark what changes caused differences
  .tags('v1')
  // actual benchmarks
  .add('1 * 1', () => 1 * 1)
  .add('1 + 1', () => 1 + 1)
  .run()

<g-emoji class=“g-emoji” alias=“ring” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f48d.png”>💍</g-emoji> async

const Bench = require('bench-chain')

const sleep = sleepDuration => new Promise(resolve => setTimeout(resolve, sleepDuration))

Bench
  .init().dir(__dirname).filename('asyncs.json').setup()
  .name('sleepy')
  .tags('v1,v2')

  // can also use .add, and then .runAsync()
  .addAsync('sleep1', async done => {
    await sleep(1000)
    done()
  })
  .addAsync('sleep2', async done => {
    await sleep(2000)
    done()
  })
  .run()

<g-emoji class=“g-emoji” alias=“triangular_flag_on_post” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f6a9.png”>🚩</g-emoji> flags

using funwithflags

  • --graph will show only the graph reporting, rather than run the benchmarks
  • --run-times=10 will run the test 10 times

<g-emoji class=“g-emoji” alias=“card_index” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f4c7.png”>📇</g-emoji> metadata

<details><summary><g-emoji class=“g-emoji” alias=“battery” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f50b.png”>🔋</g-emoji> battery parsing when available</summary> - will be used for comparing more benchmark results with averages - amperage (number) - currentCapacity (number) - percent (number) - charging (boolean) - temp (number)</details>

  • mem: operating system memory, nodejs memory
  • num: operations a second from benchmarkjs hertz
  • sampled: total runs samples from benchmarkjs
  • variation: variation from benchmarkjs
  • timesFor: microtime | performance.now times for beginning & end of each run
  • now: Date.now for changes over time

graphs for trends and variation

screen shot 2017-04-29 at 9 08 50 pm

grouped by tags

screen shot 2017-05-01 at 5 45 33 am

progress bars

digress progress

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65801.html

文章标题:bench-chain

回到顶部