summaryrefslogtreecommitdiff
path: root/date-fns/src/isBefore/benchmark.js
diff options
context:
space:
mode:
Diffstat (limited to 'date-fns/src/isBefore/benchmark.js')
-rw-r--r--date-fns/src/isBefore/benchmark.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/date-fns/src/isBefore/benchmark.js b/date-fns/src/isBefore/benchmark.js
new file mode 100644
index 0000000..d70f2e8
--- /dev/null
+++ b/date-fns/src/isBefore/benchmark.js
@@ -0,0 +1,23 @@
+// @flow
+/* eslint-env mocha */
+/* global suite, benchmark */
+
+import isBefore from '.'
+import moment from 'moment'
+
+suite('isBefore', function () {
+ benchmark('date-fns', function () {
+ return isBefore(this.dateA, this.dateB)
+ })
+
+ benchmark('Moment.js', function () {
+ return this.momentA.isBefore(this.momentB)
+ })
+}, {
+ 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')
+ }
+})