Is there a cost to comments (v2)

Revision 2 of this benchmark created on


Description

See if there's any measurable cost to comments.

Setup

var result;

Test runner

Ready to run.

Testing in
TestOps/sec
With comments
// MORE COMMENTS!!!!
// MORE COMMENTS!!!!
// MORE COMMENTS!!!!
result = (function() {
    /* This is more comments!!!!!! */
    /* This is more comments!!!!!! */
    /* This is more comments!!!!!! */
    /* This is more comments!!!!!! */
    /* Total starts at 1 */
    /* Counter starts at 1,000 */
    var total = 1,
        counter = 500;

// MORE COMMENTS!!!!
    /* Loop through doing
       some work */
    while (--counter) {
        /* Add the length of the string to the total */
        total += String(total).length;
        /* Completely gratuitous comment */
    }

    // All done
    return total;
})();
// MORE COMMENTS!!!!
if (result !== 1580) throw "Error in test";
ready
No comments
result = (function() {
    var total = 1,
        counter = 500;

    while (--counter) {
        total += String(total).length;
    }

    return total;
})();
if (result !== 1580) throw "Error in test";
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.