As some of you probably noticed jsperf is down for some time. But I still need to profile my Javascripts. Is there any possibility to do comparison tests ideally without the help of an external software?
-
9You could use jsfiddle (or jsbin, plunker, codepen etc...) and benchmark.js altogether. Here is a template : jsfiddle.net/533hc71h. It won't compile all run results otherwise will work as jsperf.com does.– GhetolayJun 13, 2016 at 13:05
-
@Ghetolay this is a very useful link. Please post this as an answer +1 from me– gurvinder372Jun 14, 2016 at 9:06
-
Sorry, I had to remove the software recommendation part of your question to make is salvageable.– peterhAug 28, 2016 at 13:25
-
3Another -not offline- alternative to jsperf is jsben.ch– EscapeNetscapeNov 7, 2016 at 12:16
-
1jsperf.app seems to be a mirror made before 5/7/2015, likely after 3/26/2015.– rootApr 2 at 8:06
5 Answers
I decided to build tool like this. First public beta is at https://jsbench.me
EDIT: 2020-07-12 - v1 released
-
2So much better than jsperf. Still, if it's OSS you've got yourself a contributor. Mar 1, 2018 at 6:07
-
2probably will be sooner or later. The only reason it is not is that it started as learning project and I wanted to hide my ugly source code :) Mar 6, 2018 at 11:56
-
43In the light of JSperf being (again) down and other sites shutting down, I just wanted to (re)confirm jsbench.me is going steady and I have no plans to shut it down. New major update, v1, was released few months ago. It runs about 14.000 tests monthly now. We surpassed AWS free tier for DynamoDB so for a few months I've been paying for this. Not much though. But a bit of optimization is on the way and some kind of monetization to keep the AWS bill down. Plan for this year is to opensource it too. Code is clean enough now :) Oct 3, 2020 at 21:47
-
3Just discovered this tool today. It is a great alternative to jsPerf imho. Also I think this tool needs more exposure, give this answer an upvote, and a star on GitHub, I did so already.– nikitahlNov 5, 2020 at 8:25
-
2This answer would be better if it showed an example of the service's use. Currently, this is essentially a link-only answer. Jun 1, 2021 at 0:07
jsperf is based on benchmarkjs so using an online code editor (like jsfiddle, jsbin, plunker etc...) and including benchmarkjs as a library will do.
The only feature you won't have will be the compiled results for each browsers. This is just a temporary alternative.
Here is a jsfiddle template : https://jsfiddle.net/533hc71h/
But since we don't really care about HTML nor CSS I found plunker more suitable. Coupled with systemjs you can then separate your code into multiple files.
Here is the template : https://plnkr.co/edit/pJg5LsiSNqlc6immmGsW
Update
You really should only use those solution as quick temporary solution. As said on the comments for optimal result you had better run it locally, nowadays you can get a webserver like express or else running in sec.
Rather than "trick" Stack Overflow into allowing posting of these links, let's actually include some helpful code:
function test1() {
}
function test2() {
}
var cycleResults = document.getElementById('cycleResults');
var result = document.getElementById('result');
var btn = document.getElementById('btn');
// BENCHMARK ====================
btn.onclick = function runTests() {
btn.setAttribute('disable', true);
cycleResults.innerHTML = '';
result.textContent = 'Tests running...';
var suite = new Benchmark.Suite;
// add tests
suite
.add('test1', test1)
.add('test2', test2)
// add listeners
.on('cycle', function(event) {
var result = document.createElement('li');
result.textContent = String(event.target);
document.getElementById('cycleResults')
.appendChild(result);
})
.on('complete', function() {
result.textContent = 'Fastest is ' + this.filter('fastest').pluck('name');
btn.setAttribute('disable', false);
})
// run async
.run({
'async': true
});
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<ul id='cycleResults'>
</ul>
<div id="result">
</div>
<br>
<button id="btn">
Run Tests
</button>
-
1Be very careful about running benchmarks in one of these common bin providers. I'm not sure about the others, but jsbin injects a lot of "magic" code inline to provide certain features, the most harmful in this case being infinite loop protection that may drastically skew your results, depending on how your tests are written.
//no-protect
comment disables that particular thing, but even then there are others. I don't believe it injects into your external dependencies though, so benchmark internals shouldn't be affected. Oct 19, 2016 at 5:23 -
1@JayPhelps you'll still be able to compare tests since they should all be affected the same way. Now like I said this was a temporary solution.– GhetolayOct 19, 2016 at 8:03
-
Ghetolay, your plnkr.co link doesn't work. It shows: "Unable to connect to any application instances". :( Oct 21, 2016 at 12:18
-
This errors occurs sometimes on plnkr globally it's not specific to my plnkr link. Just try it again, right now it's working.– GhetolayOct 23, 2016 at 21:41
-
Improved a bit on the jsfiddle template, namely dynamically defined test functions, improved visual output via a table & named tests after function name, and test error feedback. jsfiddle.net/2e8fcuhb/2– BAM5Oct 7, 2020 at 4:15
There is also https://www.measurethat.net/ which allows you to create and run javascript benchmarks
-
1Promising, but as of now there's no search and it requires an OAuth login (can't do a local password). Sep 9, 2016 at 12:51
-
1Yeah, I am working on improving it. There are opened issues for what you mentioned and I expect them to be addressed soon: github.com/thecoderok/MeasureThat.net/issues/52 github.com/thecoderok/MeasureThat.net/issues/37 github.com/thecoderok/MeasureThat.net/issues/47– vmgSep 9, 2016 at 15:45
-
2
-
2I like the UI @vmg ! And I did some useful stuff with it tonight, so thanks! I know it's in progress.. I had a number of errors tonight (Oh Snap), I suspect around what are valid names for test cases... But it's a nice tool.. FYI measurethat.net/Benchmarks/ShowResult/1516 Sep 30, 2016 at 2:58
-
1I started to migrate all my
jsperf
snippets that are dead at the moment tomeasurethat
. Thanks for the great effort. Dec 19, 2018 at 9:41
I have incidentally come to know http://jsbench.github.io/.
It clearly reminds of good ol' jsperf.
You can save your benchmark, share them and they keep track of per-browser performance.
Here is one I just made up: For loop benchmark
(As a side note, you can only save a benchmark if you have a github account.)
-
1But it wants read and write access to all gists, if you want to save... Don't like that. Apart from that it appears to be quite useful. Although the graph looks buggy to me.– NeonitDec 15, 2016 at 16:44
-
I agree on all points. A weird thing is that mobile browser labels do not always specify the platform on which the test was run.– SpyrytoJan 3, 2017 at 10:35
Even though jsperf is online, if you still want to look at alternatives, I found https://jsben.ch/ to be quite useful and well designed.
-
This answer would be better if it showed an example of the service's use. Currently, this is essentially a link-only answer. Jun 1, 2021 at 0:11