-
-
Save DracoBlue/791545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var one = 'http://blah' | |
, two = '/asdf/asdf/af' | |
; | |
function regexTest () { | |
var start = new Date(); | |
var i = 0; | |
while (i<1000000) { | |
if ( !/^http?:/.test(one) ) true | |
if ( !/^http?:/.test(two) ) true | |
i++; | |
} | |
var end = new Date(); | |
console.log('regexTest: '+(end - start)) | |
} | |
function sliceTest () { | |
var start = new Date(); | |
var i = 0; | |
while (i<1000000) { | |
if (one.slice(0, 'http'.length) === 'http') true | |
if (two.slice(0, 'http'.length) === 'http') true | |
i++ | |
} | |
var end = new Date(); | |
console.log('sliceTest: '+(end - start)) | |
} | |
function indexOfTest () { | |
var start = new Date(); | |
var i = 0; | |
while (i<1000000) { | |
if ('http'.indexOf(one) === 0) true | |
if ('http'.indexOf(two) === 0) true | |
i++ | |
} | |
var end = new Date(); | |
console.log('indexOfTest: '+(end - start)) | |
} | |
regexTest(); | |
sliceTest(); | |
indexOfTest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment