-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathdate_YYYYMMDD.cjs
32 lines (28 loc) · 1 KB
/
date_YYYYMMDD.cjs
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
28
29
30
31
32
/* eslint-disable @typescript-eslint/no-var-requires */
// http://jsperf.com/access-log-date-format
const moment = require('moment');
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const utils = require('..');
const suite = new Benchmark.Suite();
console.log('parseInt(moment().format("YYYYMMDD"), 10): %j', parseInt(moment().format('YYYYMMDD'), 10));
console.log('utils.datestruct().YYYYMMDD: %j', utils.datestruct().YYYYMMDD);
console.log('new Date().toString(): %j', new Date().toString());
console.log('------------------------');
suite
.add("parseInt(moment().format('YYYYMMDD'), 10)", function() {
parseInt(moment().format('YYYYMMDD'), 10);
})
.add('utils.datestruct().YYYYMMDD', function() {
utils.datestruct().YYYYMMDD;
})
.add('new Date().toString()', function() {
new Date().toString();
})
.on('cycle', function(event) {
benchmarks.add(event.target);
})
.on('complete', function() {
benchmarks.log();
})
.run({ async: false });