Created
April 30, 2013 20:03
-
-
Save sgreenfield/5491501 to your computer and use it in GitHub Desktop.
Sugar.js v.s. native Date v.s. tzDate - Performance tests
This file contains 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
console.clear(); | |
var amountOfTests = 5000, | |
newDate, tzDateMake, dateCreate, tzDateCreate; | |
console.time('new Date'); | |
amountOfTests.times(function(){ | |
newDate = new Date("2010-12-26T06:00:00Z"); | |
}); | |
console.timeEnd('new Date'); | |
console.time('tzDate.make'); | |
amountOfTests.times(function(){ | |
tzDateMake = tzDate.make( (new Date("2010-12-26T06:00:00Z")) )._dateProxy; | |
}); | |
console.timeEnd('tzDate.make'); | |
console.time('Date.create'); | |
amountOfTests.times(function(){ | |
dateCreate = Date.create("2010-12-26T06:00:00Z"); | |
}); | |
console.timeEnd('Date.create'); | |
console.time('tzDate.create'); | |
amountOfTests.times(function(){ | |
tzDateCreate = tzDate.create("2010-12-26T06:00:00Z")._dateProxy; | |
}); | |
console.timeEnd('tzDate.create'); | |
//all dates except for "newDate" should also be timezone-specific | |
console.warn('These dates should all be the same! ', newDate, tzDateMake, dateCreate, tzDateCreate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment