ben

2018-11-09 admin

ben是什么

什么是ben,simple timing benchmarks for synchronous and asynchronous code

ben使用教程帮助文档

ben

Benchmark synchronous and asynchronous snippets simply.

ben the big

examples

synchronous

var ben = require('ben');

var ms = ben(function () {
    JSON.parse('[1,2,3]')
});

console.log(ms + ' milliseconds per iteration');

output:

0.0024 milliseconds per iteration

asynchronous

var ben = require('ben');

var test = function (done) {
    setTimeout(done, 10);
};

ben.async(test, function (ms) {
    console.log(ms + ' milliseconds per iteration');
});

output:

10.39 milliseconds per iteration

methods

ben(times=10000, testFn)

Return how many milliseconds it takes to execute testFn.

testFn will be executed times many times.

alias: ben.sync()

ben.async(times=100, testFn, cb)

Compute how many milliseconds it takes to complete the asynchronous function testFn. testFn(done) will be called with a done callback to move along to the next iteration.

After testFn is run times many times, cb will be called with the number of milliseconds on average that testFn took to finish.

install

With npm, do:

npm install ben

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

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

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

文章标题:ben

相关文章
jsbench
jsbench是什么 什么是jsbench,A very small javascript benchmark tool! jsbench官网:官网 jsbench源码仓库:源码仓库 jsbench下载地址:点此下载 点此下载2 jsb...
2018-10-10
Is there a benefit to using a return statement that returns nothing?
Jonathan LefflerStephen提出了一个问题:Is there a benefit to using a return statement that returns nothing?,或许与您遇到的问题类似。 回答者Guff...
2018-04-17
Is there a benefit to minifying JavaScript before gzipping it?
Mark AmerySteve Steiner提出了一个问题:Is there a benefit to minifying JavaScript before gzipping it?,或许与您遇到的问题类似。 回答者Jim Ferran...
2018-04-19
karma-benchmark
karma-benchmark是什么 什么是karma-benchmark,Continuous JavaScript Performance Monitoring with Benchmark.js and the Karma Runne...
2018-10-13
What are the benefits of a directive template function in Angularjs?
Maksym Bykovskyy提出了一个问题:What are the benefits of a directive template function in Angularjs?,或许与您遇到的问题类似。 回答者Phil Degenh...
2018-04-13
abend
abend是什么 什么是abend,Throw an error if there is an error. abend官网:官网 abend源码仓库:源码仓库 abend下载地址:点此下载 点此下载2 abend使用教程帮助文档 ...
2018-09-14
What are the benefits to using anonymous functions instead of named functions for callbacks and parameters in JavaScript event code?
CœurDoug Stephen提出了一个问题:What are the benefits to using anonymous functions instead of named functions for callbacks and ...
2018-04-22
eslint-config-benoitz
eslint-config-benoitz是什么 什么是eslint-config-benoitz,Default ESLint configuration for my projects eslint-config-benoitz官网:...
2018-09-18
karma-benchmark-reporter
karma-benchmark-reporter是什么 什么是karma-benchmark-reporter,A Karma benchmark reporter karma-benchmark-reporter官网:官网 karma-...
2018-10-13
Benefits of "Use Strict" in JS [duplicate]
TMacGyver提出了一个问题:Benefits of “Use Strict” in JS [duplicate],或许与您遇到的问题类似。 回答者Communityjfriend00给出了该问题的处理方式: There are a z...
2018-04-15
回到顶部