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.Ghetolay– Ghetolay2016-06-13 13:05:02 +00:00Commented Jun 13, 2016 at 13:05
-
@Ghetolay this is a very useful link. Please post this as an answer +1 from megurvinder372– gurvinder3722016-06-14 09:06:34 +00:00Commented Jun 14, 2016 at 9:06
-
Sorry, I had to remove the software recommendation part of your question to make is salvageable.peterh– peterh2016-08-28 13:25:29 +00:00Commented Aug 28, 2016 at 13:25
-
3Another -not offline- alternative to jsperf is jsben.chEscapeNetscape– EscapeNetscape2016-11-07 12:16:41 +00:00Commented Nov 7, 2016 at 12:16
-
2jsperf.app seems to be a mirror made before 5/7/2015, likely after 3/26/2015.root– root2023-04-02 08:06:44 +00:00Commented Apr 2, 2023 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
9 Comments
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>
5 Comments
//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.There is also https://www.measurethat.net/ which allows you to create and run javascript benchmarks
6 Comments
jsperf snippets that are dead at the moment to measurethat. Thanks for the great effort.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.)
2 Comments
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.