diff options
Diffstat (limited to 'date-fns/src/differenceInMonths/benchmark.js')
-rw-r--r-- | date-fns/src/differenceInMonths/benchmark.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/date-fns/src/differenceInMonths/benchmark.js b/date-fns/src/differenceInMonths/benchmark.js new file mode 100644 index 0000000..4c2f1c7 --- /dev/null +++ b/date-fns/src/differenceInMonths/benchmark.js @@ -0,0 +1,23 @@ +// @flow +/* eslint-env mocha */ +/* global suite, benchmark */ + +import differenceInMonths from '.' +import moment from 'moment' + +suite('differenceInMonths', function () { + benchmark('date-fns', function () { + return differenceInMonths(this.dateA, this.dateB) + }) + + benchmark('Moment.js', function () { + return this.momentA.diff(this.momentB, 'month') + }) +}, { + setup: function () { + this.dateA = new Date() + this.momentA = moment() + this.dateB = new Date(this.dateA.getTime() + 604800000) + this.momentB = this.momentA.clone().add(7, 'days') + } +}) |