User:Mike Dillon/Scripts/bench.js

Hello, you have come here looking for the meaning of the word User:Mike Dillon/Scripts/bench.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Mike Dillon/Scripts/bench.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Mike Dillon/Scripts/bench.js in singular and plural. Everything you need to know about the word User:Mike Dillon/Scripts/bench.js you have here. The definition of the word User:Mike Dillon/Scripts/bench.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Mike Dillon/Scripts/bench.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// Requires ]

function timeFunction (n, f) {
    var start = new Date();

    // Execute n iterations of function f()
    for (var i = 0; i < n; i++) {
        f();
    }

    return new Date().getTime() - start.getTime();
}

function compareFunctions (n, funcs) {
    var fns = new Array();
    var times = {};

    // Go through the function hash and time each one for n iterations
    for (var fn in funcs) {
        var f = funcs;
        var t = timeFunction(n, f);
        fns = fn;
        times = t;
    }

    // Sort the function label list by execution time descending
    fns.sort(function (a, b) { return times - times; });

    // Start the table that will be returned
    var table = easydom.table({ "class": "wikitable" });

    // Build the header row
    var header = easydom.tr(
        easydom.th(),
        easydom.th("Count"),
        easydom.th("Time"),
        easydom.th("Rate")
    );
    for (var i in fns) {
        header.appendChild(easydom.th(fns));
    }
    table.appendChild(header);

    // Build the data rows for each function using fns for order
    for (var i in fns) {
        var fn = fns;
        var ft = times;

        // Begin row with function label, count, time, and rate
        var row = easydom.tr(
            easydom.th(fn),
            easydom.td(n),
            easydom.td(times + " ms"),
            easydom.td(Math.round(n / (times / 1000)) + "/s")
        );

        // Fill in comparisons with other functions
        for (var j in fns) {
            var fn2 = fns;

            var cmp;
            if (fn == fn2) {
                cmp = "--";
            } else {
                // Calculate percentage difference relative to column rate
                var ft2 = times;
                var diff = (ft2 - ft) / ft2;
                cmp = (diff > 0 ? "+" : "");
                cmp += Math.round(1000 * diff) / 10;
                cmp += "%";
            }
            row.appendChild(easydom.td(cmp));
        }

        // Add the data row to the table
        table.appendChild(row);
    }

    // Return the table's DOM node
    return table;
}