<commit_before>require("es6-shim");
var transit = require("../target/transit.js");

function time(f, iters) {
    iters = iters || 1;
    for(var i = 0; i < iters; i++) {
        var s = new Date();
        f();
        console.log("Elapsed "+((new Date()).valueOf()-s.valueOf())+"ms");
        console.log("----------");
    }
}

console.log("Add 1e4 entries es6-shim Map");
time(function() {
    var m = new Map();
    for(var i = 0; i < 10000; i++) {
        m.set(["foo"+i], i);
    }
});

console.log("Add 1e4 entries, transit map");
time(function() {
    var m = transit.map();
    for(var i = 0; i < 10000; i++) {
        m.set(["foo"+i], i);
    }
});

var es6m = new Map(),
    ks   = [];
for(var i = 0; i < 10000; i++) {
    var k = ["foo"+i];
    es6m.set(k, i);
    ks.push(k);
}

var tm = transit.map();
for(var i = 0; i < 10000; i++) {
    tm.set(["foo"+i], i);
}

console.log("has 1e4 entries es6-shim Map");
time(function() {
    var has = true;
    for(var i = 0; i < 10000; i++) {
        has = has && es6m.has(ks[i]);
    }
    console.log(has);
});

console.log("has 1e4 entries transit map");
time(function() {
    var has = true;
    for(var i = 0; i < 10000; i++) {
        has = has && tm.has(["foo"+i]);
    }
    console.log(has);
});

es6m = new Map();
for(var i = 0; i < 1000000; i++) {
    es6m.set(i, i);
}

tm = transit.map();
for(var i = 0; i < 1000000; i++) {
    tm.set(i, i);
}

console.log("forEach 1e6 entries es6-shim Map");
time(function() {
    var s = 0;
    es6m.forEach(function(v, k) {
        s = s + v;
    });
    console.log(s);
});

console.log("forEach 1e6 entries transit map");
time(function() {
    var s = 0;
    tm.forEach(function(v, k) {
        s = s + v;
    });
    console.log(s);
});<commit_msg>make it possible to test against V8 Harmony Map/Set<commit_after>require("es6-shim");
var transit = require("../target/transit.js");

function time(f, iters) {
    iters = iters || 1;
    for(var i = 0; i < iters; i++) {
        var s = new Date();
        f();
        console.log("Elapsed "+((new Date()).valueOf()-s.valueOf())+"ms");
        console.log("----------");
    }
}

console.log("Add 1e4 entries es6-shim Map");
time(function() {
    var m = new Map();
    for(var i = 0; i < 10000; i++) {
        m.set(["foo"+i], i);
    }
});

console.log("Add 1e4 entries, transit map");
time(function() {
    var m = transit.map();
    for(var i = 0; i < 10000; i++) {
        m.set(["foo"+i], i);
    }
});

var es6m = new Map(),
    ks   = [];
for(var i = 0; i < 10000; i++) {
    var k = ["foo"+i];
    es6m.set(k, i);
    ks.push(k);
}

var tm = transit.map();
for(var i = 0; i < 10000; i++) {
    tm.set(["foo"+i], i);
}

console.log("has 1e4 entries es6-shim Map");
time(function() {
    var has = true;
    for(var i = 0; i < 10000; i++) {
        has = has && es6m.has(ks[i]);
    }
    console.log(has);
});

console.log("has 1e4 entries transit map");
time(function() {
    var has = true;
    for(var i = 0; i < 10000; i++) {
        has = has && tm.has(["foo"+i]);
    }
    console.log(has);
});

es6m = new Map();
for(var i = 0; i < 1000000; i++) {
    es6m.set(i, i);
}

tm = transit.map();
for(var i = 0; i < 1000000; i++) {
    tm.set(i, i);
}

console.log("forEach 1e6 entries es6-shim Map");
if(es6m.forEach) {
    time(function() {
        var s = 0;
        es6m.forEach(function(v, k) {
            s = s + v;
        });
        console.log(s);
    });
}

console.log("forEach 1e6 entries transit map");
time(function() {
    var s = 0;
    tm.forEach(function(v, k) {
        s = s + v;
    });
    console.log(s);
});
{'fraction_non_alphanumeric': 0.22549291863371285, 'fraction_numerical': 0.04387670091641211, 'mean_word_length': 2.304587155963303, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2919346', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1422, 'n_words': 363}