PersistentVector.cljs

JavaScript performance comparison

Revision 12 of this test case created

Preparation code

<script src="https://raw.github.com/swannodette/persistent-vector/master/persistent-vector.js"></script>

<script src="https://raw.github.com/laczoka/persistent-vector/master/pvector.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var pa = [];
    for(var i = 0; i < 10000; i++) {
      pa.push(i);
    }
    var pv = new PersistentVector(0, 5, EMPTY_NODE, []);
    for(var i = 0; i < 10000; i++) {
      pv = pv.cons(i);
    }
    var pv2 = pvector.makeemptyvector();
    for(var i = 0; i < 10000; i++) {
      pv2 = pvector.conjwrapper(pv2,i);
    }
    var pv3 = pvector.makeemptypvector();
    for(var i = 0; i < 10000; i++) {
      pv3 = pvector.conjwrapper(pv3,i);
    }
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
build PVector - handwritten JS
var v = EMPTY;
for(var i = 0; i < 10000; i++) {
  v = v.cons(i);
}
pending…
build PVector - CLJS implementation
var v = pvector.makeemptypvector();
for(var i = 0; i < 10000; i++) {
  v = pvector.conjwrapper(v,i);
}
pending…
build Vector - copy on write
var v = pvector.makeemptyvector();
for(var i = 0; i < 10000; i++) {
  v = pvector.conjwrapper(v,i);
}
pending…
build PVector - CLJS small size
var v = pvector.makeemptypvector();
for(var j = 0; j < 312; j++) {
  for(var i = 0; i < 32; i++) {
    v = pvector.conjwrapper(v,i);
  }
}
pending…
build Vector - small size
var v = pvector.makeemptyvector();
for(var j = 0; j < 312; j++) {
  for(var i = 0; i < 32; i++) {
    v = pvector.conjwrapper(v,i);
  }
}
pending…
mutable array
var v = [];
for(var i = 0; i < 10000; i++) {
  v[i] = i;
}
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:

0 comments

Add a comment