summaryrefslogtreecommitdiff
path: root/date-fns/src/formatDistanceToNowStrict/benchmark.js
blob: 47d9e082b9f4a36c91f6a75b966e19a60a556ab0 (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
// @flow
/* eslint-env mocha */
/* global suite, benchmark */

import formatDistanceToNowStrict from '.'
import moment from 'moment'

suite(
  'formatDistanceToNowStrict',
  function() {
    benchmark('date-fns', function() {
      return formatDistanceToNowStrict(this.date)
    })

    benchmark('Moment.js', function() {
      return this.moment.toNow()
    })
  },
  {
    setup: function() {
      this.date = new Date()
      this.moment = moment()
    }
  }
)