Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added benchmarks for some supported operations
- Loading branch information
1 parent
cbc3621
commit 6f9f5b0
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
var Benchmark = require('benchmark'), | |||
moment = require("./../moment.js"), | |||
base = moment('2013-05-25'); | |||
|
|||
var unitsUnderTest = ["milliseconds", "seconds", "minutes", "hours", "days", "weeks", "months", "quarters", "years"]; | |||
var tests = unitsUnderTest.reduce(function (testsSoFar, unit) { | |||
testsSoFar["add " + unit] = generateTestForUnit(unit); | |||
return testsSoFar; | |||
}, {}); | |||
|
|||
function generateTestForUnit(unit) { | |||
return { | |||
setup: function(){var base = base; var unit = unit;}, | |||
fn: function(){base.add(8, unit);}, | |||
async: true | |||
}; | |||
} | |||
|
|||
module.exports = { | |||
name: 'add', | |||
tests: 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
var Benchmark = require('benchmark'), | |||
moment = require("./../moment.js"), | |||
base = moment('2013-05-25'); | |||
|
|||
var unitsUnderTest = ["second", "minute", "hour", "date", "day", "isoWeek", "week", "month", "quarter", "year"]; | |||
var tests = unitsUnderTest.reduce(function (testsSoFar, unit) { | |||
testsSoFar["endOf " + unit] = generateTestForUnit(unit); | |||
return testsSoFar; | |||
}, {}); | |||
|
|||
function generateTestForUnit(unit) { | |||
return { | |||
setup: function(){var base = base; var unit = unit;}, | |||
fn: function(){base.endOf(unit);}, | |||
async: true | |||
}; | |||
} | |||
|
|||
module.exports = { | |||
name: 'endOf', | |||
tests: 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
var Benchmark = require('benchmark'), | |||
moment = require("./../moment.js"), | |||
base = moment('2013-05-25'); | |||
|
|||
|
|||
module.exports = { | |||
name: 'clone', | |||
tests: { | |||
isBefore_true: { | |||
onComplete: function(){}, | |||
fn: function(){base.isBefore('2013-06-25');}, | |||
async: true | |||
}, | |||
isBefore_self: { | |||
onComplete: function(){}, | |||
fn: function(){base.isBefore('2013-05-25');}, | |||
async: true | |||
}, | |||
isBefore_false: { | |||
onComplete: function(){}, | |||
fn: function(){base.isBefore('2013-04-25');}, | |||
async: true | |||
}, | |||
isAfter_true: { | |||
onComplete: function(){}, | |||
fn: function(){base.isAfter('2013-04-25');}, | |||
async: true | |||
}, | |||
isAfter_self: { | |||
onComplete: function(){}, | |||
fn: function(){base.isAfter('2013-05-25');}, | |||
async: true | |||
}, | |||
isAfter_false: { | |||
onComplete: function(){}, | |||
fn: function(){base.isAfter('2013-06-25');}, | |||
async: true | |||
} | |||
} | |||
}; |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
var Benchmark = require('benchmark'), | |||
moment = require("./../moment.js"), | |||
base = moment('2013-05-25'); | |||
|
|||
var unitsUnderTest = ["second", "minute", "hour", "date", "day", "isoWeek", "week", "month", "quarter", "year"]; | |||
var tests = unitsUnderTest.reduce(function (testsSoFar, unit) { | |||
testsSoFar["startOf " + unit] = generateTestForUnit(unit); | |||
return testsSoFar; | |||
}, {}); | |||
|
|||
function generateTestForUnit(unit) { | |||
return { | |||
setup: function(){var base = base; var unit = unit;}, | |||
fn: function(){base.startOf(unit);}, | |||
async: true | |||
}; | |||
} | |||
|
|||
module.exports = { | |||
name: 'startOf', | |||
tests: 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
var Benchmark = require('benchmark'), | |||
moment = require("./../moment.js"), | |||
base = moment('2013-05-25'); | |||
|
|||
var unitsUnderTest = ["milliseconds", "seconds", "minutes", "hours", "days", "weeks", "months", "quarters", "years"]; | |||
var tests = unitsUnderTest.reduce(function (testsSoFar, unit) { | |||
testsSoFar["subtract " + unit] = generateTestForUnit(unit); | |||
return testsSoFar; | |||
}, {}); | |||
|
|||
function generateTestForUnit(unit) { | |||
return { | |||
setup: function(){var base = base; var unit = unit;}, | |||
fn: function(){base.subtract(8, unit);}, | |||
async: true | |||
}; | |||
} | |||
|
|||
module.exports = { | |||
name: 'subtract', | |||
tests: tests | |||
}; |