Questions tagged [benchmark.js]

A robust benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results.

Benchmark.js site
Documentation

27 questions
16
votes
3 answers

Define number of cycles - Benchmark.js

I am trying to execute a sample performance benchmark using Benchmark.js. Here is what I have wrote: var Benchmark = require('benchmark'); var arr = [] benchmark = new Benchmark('testPerf',function(){ arr.push(1000); }, { delay: 0, …
Tariq
  • 2,489
  • 11
  • 36
  • 61
15
votes
2 answers

Benchmark Asynchronous Code (Benchmark.js, Node.js)

I'd like to use the Benchmark.js module to test some asynchronous code written in node.js. Specifically, I want to fire ~10,000 requests to two servers (one written in node, one written in PHP), and track how long it takes for each server to…
opensourcejunkie
  • 518
  • 7
  • 14
14
votes
1 answer

What do the results from benchmark js mean?

I am using a version of Benchmark JS for node and I can't find any information about how to read the results. Firstly, is there a place that details what all the data you can extract from Benchmark JS? Secondly I am currently getting the following…
McShaman
  • 3,627
  • 8
  • 33
  • 46
10
votes
1 answer

How to measure DOM rendering time Angular 2 app?

While I am develping web application using Angular 2, I came to have question about performance test like how to measure loading time in Angular2?. Therefore, I got a very helpful answer, I could start to do performance test. However, I would like…
Anna Lee
  • 909
  • 1
  • 17
  • 37
7
votes
1 answer

Benchmarking WebCrypto is much slower than third-party libraries?

I am evaluating how WebCrypto performance compares to third-party crypto libraries SJCL and Forge. I would expect WebCrypto to be much faster since it is a native browser implementation. This has also been benchmarked before and has shown such. I…
kspearrin
  • 10,238
  • 9
  • 53
  • 82
7
votes
1 answer

How to add setup and teardown for each test in benchmark.js

I am new to using benchmark.js, the documentation is bit jarring, and not able to find many examples, can anyone please confirm if my code is correct, sorry i cannot share the whole code( company policy). consider setText(choice); as some operation,…
mido
  • 24,198
  • 15
  • 92
  • 117
5
votes
1 answer

Why is the purpose for setup, teardown, and cycles in Benchmark.js?

I know the formal descriptions: Setup: create the expected state for the test. Teardown: Do necessary clean-up operations. However, why is this necessary, especially in Benchmark.js ? Why the need for different test cycles (as defined in…
doubleOrt
  • 2,407
  • 1
  • 14
  • 34
5
votes
0 answers

what makes two same objects performance different?

source define two object both with getter and setter, with the same code both test with benchmark.js in node v7.3.0 const builtInObject1 = (function (object) { let lastA = 1; return Object.defineProperties(object, { a:{ …
tommyZZM
  • 83
  • 6
4
votes
1 answer

Benchmarking asynchronous vs synchronous code that throws an error

I have two functions; one is async (testAsync) and one is sync (testSync). I'm trying to use them with benchmark.js. Which one is faster and by how much. They should both throw an error. I'm confused how I'm supposed to a) setup an asynchronous…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
4
votes
1 answer

How to display/read results (ops/sec)?

I am able to successfully create and run benchmark suite, but not sure how to get the benchmark values of each output, this.filter('fastest').pluck('name') in onComplete gives me the name of the fastest operation, but I want the ops/sec value of…
mido
  • 24,198
  • 15
  • 92
  • 117
3
votes
0 answers

How to use external library 'benchmark.js' in Angular2?

I am developing application using Angular2. I am trying to import and use external library 'benchmark.js'. So, I install it using 'npm i --save benchmark'. The dependencies of package.json is like following. "name": "angular2-webpack", "version":…
Anna Lee
  • 909
  • 1
  • 17
  • 37
2
votes
1 answer

Using Benchmarkjs with Webpack and Babel

I'm trying to get some basic benchmark tests working and am having trouble figuring out the right configuration. I'm trying to use Benchmarkjs with webpack and babel to transpile my code to es5. I created a benchmarks.webpack.js as an entry point…
Bill
  • 25,119
  • 8
  • 94
  • 125
1
vote
0 answers

Benchmark.js when used in '.jsx' file throws error "Critical dependency: the request of a dependency is an expression"

I am trying to get benchmark results of a loop used and display it. My code: import Benchmark from 'benchmark'; import React, { useState } from 'react'; import Navigation from '../Navigation/Navigation'; const Array = () => { const suite = new…
1
vote
2 answers

How to get Benchmark.js to do setup/teardown each time my benchmarked code is run (not just each cycle)?

I am trying to benchmark an Object's member function using Benchmark.js. Testing the function is made difficult by several factors: Creation of the object is asynchronous (I could mock that part) The member function is expensive The member function…
TheJim01
  • 8,411
  • 1
  • 30
  • 54
1
vote
1 answer

How to get a report out of benchmark.js

I tried benchmark.js while it appears to be running a benchmark and showing me fastest test, i don't get how to get a nice report out of it I tried this: suite.add('My#test', function() { console.log("test") }).on('complete', function() { …
Jas
  • 14,493
  • 27
  • 97
  • 148
1
2