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

import max from '.'
import moment from 'moment'

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

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