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

相关文章
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
fastbench
fastbench是什么 什么是fastbench,the simplest benchmark you can run on node fastbench官网:官网 fastbench源码仓库:源码仓库 fastbench下载地址:点此...
2018-09-19
What is the benefit of angular.isdefined?
Ben提出了一个问题:What is the benefit of angular.isdefined?,或许与您遇到的问题类似。 回答者Alexander MikhalchenkoBharath Kumar Bachina给出了该问题的处...
2018-04-08
benv
benv是什么 什么是benv,Stub a browser environment and test your client-side code in node.js. benv官网:官网 benv源码仓库:源码仓库 benv下载地址:...
2018-12-19
bench-it
bench-it是什么 什么是bench-it,Benchmark your code bench-it官网:官网 bench-it源码仓库:源码仓库 bench-it下载地址:点此下载 点此下载2 bench-it使用教程帮助文档 b...
2018-11-19
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
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
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
benchr
benchr是什么 什么是benchr,Benchmark runner benchr官网:官网 benchr源码仓库:源码仓库 benchr下载地址:点此下载 点此下载2 benchr使用教程帮助文档 benchr Node.js b...
2018-11-23
回到顶部