New fhfhfhf (v18)

Revision 18 of this benchmark created on


Setup

var string = 'The hexadecimal color code <strong><code>{hex}</code></strong> is a {shadeLightness} shade of <strong>{shade}</strong>. In the RGB color model <code>{hex}</code> is comprised of {red}% red, {green}% green and {blue}% blue. In the HSL color space <em><code>{hex}</code></em> has a hue of {hue} degrees, {saturation}% saturation and {lightness}% lightness. This color has an <em>approximate</em> wavelength of <strong>{wavelength} nm</strong>.';

Test runner

Ready to run.

Testing in
TestOps/sec
.split('.').join(' ')
result = mystring.split('.').join(' ');
ready
.replace(/\./g,' ')
result = string.replace(/\{hex\}/g, '#0066cc');
ready
String
/**
 * ReplaceAll by Fagner Brack (MIT Licensed)
 * Replaces all occurrences of a substring in a string
 */
String.prototype.replaceAll = function( token, newToken, ignoreCase ) {
    var _token;
    var str = this + "";
    var i = -1;

    if ( typeof token === "string" ) {

        if ( ignoreCase ) {

            _token = token.toLowerCase();

            while( (
                i = str.toLowerCase().indexOf(
                    token, i >= 0 ? i + newToken.length : 0
                ) ) !== -1
            ) {
                str = str.substring( 0, i ) +
                    newToken +
                    str.substring( i + token.length );
            }

        } else {
            return this.split( token ).join( newToken );
        }

    }
return str;
};

string.replaceAll('{hex}', '#0066cc');
ready

Revisions

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