This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
489d3d9
commit c79b9d3
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable no-console */ | ||
'use strict'; | ||
|
||
var Benchmark = require('benchmark'); | ||
var moment = require('moment'); | ||
var dateFormat = require('dateformat'); | ||
var format = require('date-format'); | ||
|
||
var DateFormatter = require('../DateFormatter'); | ||
var dateFormatter = new DateFormatter(); | ||
|
||
var DATE_FORMAT = ('ZZ'); | ||
|
||
const suite = new Benchmark.Suite(); | ||
|
||
suite | ||
.add('moment', () => { | ||
moment().format(DATE_FORMAT); | ||
}) | ||
.add('date-format', () => { | ||
format(DATE_FORMAT, new Date()); | ||
}) | ||
.add('dateformat', () => { | ||
dateFormat(new Date(), DATE_FORMAT); | ||
}) | ||
.add('fast-date-format', () => { | ||
dateFormatter.format(DATE_FORMAT) | ||
}) | ||
.on('cycle', function(event) { | ||
console.log(String(event.target)); | ||
}) | ||
.on('complete', function() { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')); | ||
}) | ||
.run({ 'async': true }); |