multiline (v7)

Revision 7 of this benchmark created on


Description

Testing the performance of the multiline module. This is only a naive micro-benchmark. Please treat it as such.

https://github.com/sindresorhus/multiline

Setup

/*!
        multiline
        Multiline strings in JavaScript
        https://github.com/sindresorhus/multiline
        by Sindre Sorhus
        MIT License
    */
    (function () {
        'use strict';
    
        // start matching after: comment start block => optional whitespace => newline
        // stop matching before: last newline => optional whitespace => comment end block
        var reCommentContents = /\/\*\s*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)\s*\*\//;
    
        var multiline = function (fn) {
                if (typeof fn !== 'function') {
                        throw new TypeError('Expected a function.');
                }
    
                return fn.toString();
        };
    
        if (typeof module !== 'undefined' && module.exports) {
                module.exports = multiline;
        } else {
                window.multiline = multiline;
        }
    })();

Test runner

Ready to run.

Testing in
TestOps/sec
multiline
var str = multiline(function(){/*
<!doctype html>
<html>
        <body>
                <h1>Hello world</h1>
        </body>
</html>
*/});
ready
string concat
var str = '' +
'<!doctype html>' +
'<html>' +
'       <body>' +
'               <h1>Hello world</h1>' +
'       </body>' +
'</html>' +
'';
ready

Revisions

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