summaryrefslogtreecommitdiff
path: root/date-fns/src/isSameQuarter/benchmark.js
blob: ad6b2f46eada770b6450ce6c0f1b5c96a74e4cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// @flow
/* eslint-env mocha */
/* global suite, benchmark */

import isSameQuarter from '.'
import moment from 'moment'

suite('isSameQuarter', function () {
  benchmark('date-fns', function () {
    return isSameQuarter(this.dateA, this.dateB)
  })

  benchmark('Moment.js', function () {
    return this.momentA.isSame(this.momentB, 'quarter')
  })
}, {
  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')
  }
})