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
<script>
// Assume we have an object x, and a set of fields we're interested in. We need to find the intersection of the object fields, and this set of fields we're interested in.
// We can encode the set of fields we're interested in in a couple of ways. (An array or lookup map).
// If we encode the fields of interest in an array, then we might think it is faster to start with the array, and search the object.
// If we encode the fields we're interested in in an object map, then we could either look from that object map to x, or the other way around. This explores all possibilities.
//This test tests both directions, and even uses a lookup map, which is assumed to have been set up, that describes what the content of the array is. (Should be faster than searching the entire array,
x = {something:1, somethingElse:2, another:'cat'}
var arr =
['dog', 'cat', 'mom','dad','black','white','yellow','orange','purple'];
var lookup =
{'dog':true, 'cat':true, 'mom':true,'dad':true, 'black':true,'white':true,'yellow':true,'orange':true,'purple':true};
var countFound = 0;
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
obj iteration |
| ready |
arr iteration |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.