cljs-persistent-hash-map-vs-records-minuscule

JavaScript performance comparison

Test case created by Michał Marczyk

Info

ClojureScript PersistentHashMap performance test: assoc 4 elements onto a PHM vs. same for a defrecord with four fields vs. same for a defrecord with no fields. (NB. for the final case the extension map of the record will be a PHM.)

See CLJS-178.

For a readable version of the preparation code see https://github.com/michalmarczyk/cljs-persistent-hash-map-test.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    m = null;
    k1 = phm.make_keyword("a");
    k2 = phm.make_keyword("s");
    k3 = phm.make_keyword("d");
    k4 = phm.make_keyword("f");
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
PersistentHashMap
m = phm.empty_persistent_hash_map();
m = phm.assocwrapper(m, k1, 1);
m = phm.assocwrapper(m, k2, 2);
m = phm.assocwrapper(m, k3, 3);
m = phm.assocwrapper(m, k4, 4);
pending…
Record (fields)
m = phm.fresh_record_four_fields();
m = phm.assocwrapper(m, k1, 1);
m = phm.assocwrapper(m, k2, 2);
m = phm.assocwrapper(m, k3, 3);
m = phm.assocwrapper(m, k4, 4);
pending…
Record (extmap)
m = phm.fresh_record_no_fields();
m = phm.assocwrapper(m, k1, 1);
m = phm.assocwrapper(m, k2, 2);
m = phm.assocwrapper(m, k3, 3);
m = phm.assocwrapper(m, k4, 4);
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