summaryrefslogtreecommitdiff
path: root/date-fns/src/min/benchmark.js
blob: e2a997bb38124f1d735c40544726c3d8292c89df (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 min from '.'
import moment from 'moment'

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

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