jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
@wolframkriesing wondered what the most efficient unique
function for Array
would be: http://twitter.com/wolframkriesing/status/83847205189980160
Let’s find out!
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>
<script src="https://raw.github.com/mootools/mootools-more/master/Source/Types/Array.Extras.js"></script>
<script>
var array = [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 2, 3, 4, 1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 2, 3, 4];
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Using indexOf - O(n2) |
| ready |
Using indexOf and ~ - O(n2) |
| ready |
Using a map - O(n) |
| ready |
Using sort and filter - O((n lg n) + n) |
| ready |
using better indexOf logic |
| ready |
using simpler "in" logic |
| ready |
Moo-More unique |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.