Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.