belt difference fn
JavaScript performance comparison
Preparation code
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js"></script>
<script src="http://sjhcockrell.s3.amazonaws.com/downloads/belt.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.min.js"></script>
<script>
var lodash = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
var a = [],
b = [],
c = [];
for (var i = 0; i < 30; i+=1) {
a.push(i);
}
for (var i = 0; i < 1000; i+=1) {
b.push(i*2);
}
for (var i = 0; i < 1000; i+=1) {
c.push(i*3);
}
function ix_filter(a) {
var c = [],
len = a.length >>> 0,
i = -1,
to_subtract = B.native_concat.apply(B.ArrayInstance, arguments);
while (len > (i += 1)) {
a_i = a[i];
B.indexOf(to_subtract, a_i, len) === -1 && c.push(a_i);
}
return c;
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
B.difference - ab |
|
pending… |
lodash.difference - ab |
|
pending… |
Underscore.difference - ab |
|
pending… |
ix_filter - ab |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by John Cockrell
- Revision 2: published by John Cockrell
0 comments