What is the most accurate JS performance testing website?

After conducting a benchmark on both jsperf.com and jsben.ch, I noticed that they are providing significantly different results.

Here are the links to the benchmarks:

Even though the code blocks used in both benchmarks are identical, the performance outcomes vary greatly. On jsperf, block 1 is reported to be "61% slower" than the fastest, while on jsbench, it's only 32% slower than the fastest option.

This inconsistency is perplexing as one would expect benchmark sites to yield similar results with minimal variation.

Due to these discrepancies, I am unable to draw a definitive conclusion regarding which method is the most efficient.

EDIT

I have expanded the list of benchmarks for further analysis:

While I cannot definitively determine the best performing option, I recommend avoiding jsben.ch due to missing crucial information such as the number of runs, error margin, and operations per second, which are essential for accurate performance assessment and comparison across benchmark sites and browsers.

(Currently, is my preferred choice.)

Answer №1

Update for March 2019: There are discrepancies in results between Firefox and Chrome - perf.zone behaves oddly on Chrome, while jsben.ch behaves strangely on Firefox. Until the reasons behind this are clear, it's best to benchmark on multiple websites (avoiding jsben.ch if possible, as other sites offer more information on run statistics)

In summary: testing your code on perf.zone and jsbench.github.io shows results similar to jsperf. For various reasons, I personally trust these three websites over jsben.ch.

I recently tested string concatenation performance by combining over 1000000 single character strings (join('') is the most efficient for such large numbers). On my system, jsben.ch timed out without producing any result. Here are the links to the benchmarks:

(Dealing with jsperf's not all tests inserted issue is a hassle)

I suspect, though can't prove, that perf.zone provides slightly more reliable benchmark data:

  • While optimizing lz-string, I used jsbench.github.io for a long time but noticed significantly high error margins at times, exceeding 100%.

  • Benchmarking on mobile devices works well with jsperf.com and perf.zone, but jsbench.github.io has glitches in CSS during testing.

There might be a connection between these issues and how jsbench.github.io updates the DOM, causing some overhead affecting the benchmarks (they should consider meta-benchmarking this).

Note: While not perfect, perf.zone occasionally times out when saving benchmarks (at the worst moments) and only allows forking of code, not editing. However, its output aligns better with jsperf, and it offers a convenient "quick" mode for temporary benchmarks

Answer №2

Apologies for bringing this up again, but I thought it might be helpful for those who come across this issue in their search results.

I can't speak on behalf of others, but jsbench.me simply uses benchmark.js for its testing purposes. It's a single-page React application, which means it operates entirely within your browser and chosen engine, resulting in consistent outcomes within the same browser. Running tests in Firefox or on mobile may yield different results, as expected. However, all testing components are managed locally, with the exception of utilizing AWS DynamoDB to store test results.

By the way, I'm the creator of the tool, so it's really just a personal passion project. Currently, it doesn't incur any costs for me since it's designed to be serverless and falls within the limits of the AWS free tier. The amount of effort I put into it is directly proportional to the number of users engaging with the platform :)

Answer №3

From what I understand, one issue arises from the fact that different JavaScript engines optimize code in varying ways depending on the environment.

I conducted a test with the same function and found that it yielded different results depending on where the function was created. For instance, in one scenario it looked like this:

const lib = {}
lib.testFn = function() {
   ....
}

While in another scenario it appeared as:

const lib = {
 testFn: function() {
   ....
 },
};

And in yet another case:

function testFn() {
   ....
}

const lib = {}
lib.testFn = testFn

There was a greater than 10% difference in results for a complex function when running in the same browser, and even more variation when testing across different browsers.

This indicates that no JavaScript benchmark can be considered entirely accurate because the way in which the benchmark executes its tests - such as fetching the test script via XHR, using eval, running the test in a worker, or within an iframe - can impact the results due to how each JS engine optimizes these scenarios differently.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is Firefox triggering setTimeout function prematurely (or is Date.getTime() inaccurate)?

Encountered an unusual issue with setTimeout() in Firefox 12. It doesn't always seem to wait the correct amount of time. Could it be a problem with the date's milliseconds? Take a look at this fiddle. Setting a setTimeout for 100ms seems to exec ...

How can I destructure the newly added object in a reducer function?

Currently, I am in the process of learning how to implement redux in my application. The main functionality is that when a user clicks on a day in the calendar, a form will be displayed. Upon submission of the form, redux should take the data and store it ...

What is the best way to ask users to allow pop-ups in any browser using React.js?

Currently, I am utilizing "@azure/msal-browser": "^2.1.0" in my React SPA hosted on Azure app service. Within my App.js file, I have implemented msalInstance.acquireTokenPopup(tokenRequest) to obtain an auth token. This action prompts a pop-up in the bro ...

How can I efficiently iterate through the array of index IDs and then iterate individually through the communes, categories, and locations?

Currently, I am developing a nodejs typescript API where I am retrieving an array of objects using a map loop. The data for "communes", "category", and "location" is fetched from another API function based on the issuerId. However, I am facing issues with ...

What is the behavior of a variable when it is assigned an object?

When using the post method, the application retrieves an object from the HTML form as shown below: code : app.post("/foo", (req, res)=> { const data = req.body; const itemId = req.body.id; console.log(data); console.log(itemId); }) ...

`Proliferating values through constantly changing addition`

I am facing an issue with my code that involves 3 input fields: <div class="row"> <input onblur="calc_basic_amount();" id="rate_basic"></input> <input onblur="calc_basic_amount();" id="qty_b ...

Ways to stop user authentication in Firebase/Vue.js PRIOR to email verification

I am currently working on a Vue.js and Firebase authentication interface with an email verification feature. The setup is such that the user cannot log in until they click the verification link sent to the email address provided during the login process. ...

Incorporating a function from a separate .js file into an index.ejs view using app.js

graphs.js: contains a function that initiates an API call and retrieves an object containing an HTML link for embedding a graph. app.js: includes the following (graphs.js has been imported): var express = require("express"); var app = express(); var grap ...

The function JSON.parse(obj) is malfunctioning and throwing an error, but an online parser is displaying the data correctly

Currently, I am in the process of developing a chatApp for my portfolio. I am working with technologies such as Flask on the back-end and vanilla on the front-end to gain a better understanding of how everything works. My main goal is to display events bas ...

What is the trick to getting an accordion to expand when hovering, rather than when clicking?

Can the accordion be set to expand when hovering instead of clicking? Also, how can a different action be triggered on click? LATEST I was specifically referring to using the jQuery UI accordion widget for this functionality. ...

Issue: function is not a valid type (during mount)

Currently, I'm trying to add a feature that automatically closes all menus and modals when a user clicks outside of the specified area. Although I am successfully calling this.closeMenu(), an error is occurring stating that this.closeMenu is not reco ...

Secure User Authentication with Node.Js Express

My Node.Js / Express app has a self-made API that requires authentication. The issue I am facing is that users are prompted to authenticate through the browser (basic authentication) even if they have already logged into the app using the standard means, s ...

Possible rewrite: "Unable to use jQuery to add elements to data fetched through AJAX requests."

I am looking to add a button to copy code inside every div that has a class starting with language. The code is functioning properly, however, after attempting to retrieve data from the database using Ajax, the button no longer appears in the div as it did ...

Save the outcome of an ArrayBuffer variable into an array within a Javascript code

I'm in the process of developing an offline music player using the HTML5 FileReader and File API, complete with a basic playlist feature. One challenge I'm facing is how to store multiple selected files as an ArrayBuffer into a regular array for ...

Is there a JavaScript equivalent to the explode function in PHP with similar functionality

I'm facing an issue while attempting to split my string in JavaScript, here is the code I am using: var str = 'hello.json'; str.slice(0,4); //output hello str.slice(6,9); //output json The problem arises when trying to slice the second str ...

Encountering exception: Issue occurred post Node version upgrade, indicating "write after end" error

Initially, my Node.js application was operating smoothly under Node v10.29. Unfortunately, when I upgraded to "node" version . When the Node version was updated to 12.0, an error stating Caught exception: Error: write after end started occurring: Caught ...

What is the best way to determine the width of a div element and determine if a horizontal scroll bar is present?

Is there a way to determine if a page (div) should be printed based on whether or not a horizontal scroll bar is present within the div itself? I have a dynamically populated div (1000px) with the CSS property overflow:auto;. Ideally, I would like to prin ...

Transfer information to ajax request while simultaneously loading

I have a project that requires working with PHP, which will be time-consuming. As the process progresses, I need to send a number (possibly the percentage) to the page using an ajax call in order to update a loading bar. However, I am unsure of how to loa ...

Innovative guidelines originating from a resource attribute

I am facing a challenge with a repeater for a resource that has an attribute containing angular directives mixed with text. My goal is to display form inputs dynamically based on the object's property. <ul> <li ng-repeat="action in actions ...

What is the best way to test a React component that triggers a function in its parent, causing the component's props to be modified?

The issue at hand: The props of component Child are passed as the values of the state of Parent. Child contains a method that calls a method on Parent, which then updates the state of Parent. When Parent's state changes, one of Child's prop val ...