Skip to content

Instantly share code, notes, and snippets.

@sgreenfield
Created April 30, 2013 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgreenfield/5491501 to your computer and use it in GitHub Desktop.
Save sgreenfield/5491501 to your computer and use it in GitHub Desktop.
Sugar.js v.s. native Date v.s. tzDate - Performance tests
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