Skip to content

Commit

Permalink
bump to fast-date v3
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmarkclements committed May 14, 2018
1 parent a4631d2 commit d560a43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions benchmarks/time.bench.js
Expand Up @@ -3,13 +3,20 @@
var bench = require('fastbench')
var pino = require('../')

var iso = pino({timestamp: pino.stdTimeFunctions.isoTime}, pino.destination('/dev/null'))
var epoch = pino({timestamp: pino.stdTimeFunctions.epochTime}, pino.destination('/dev/null'))
var unix = pino({timestamp: pino.stdTimeFunctions.unixTime}, pino.destination('/dev/null'))
var utc = pino({timestamp: pino.stdTimeFunctions.utcTime}, pino.destination('/dev/null'))

var max = 100

var run = bench([
function benchPinoIsoTime (cb) {
for (var i = 0; i < max; i++) {
iso.info('hello world')
}
setImmediate(cb)
},
function benchPinoEpochTime (cb) {
for (var i = 0; i < max; i++) {
epoch.info('hello world')
Expand Down
19 changes: 14 additions & 5 deletions lib/time.js
Expand Up @@ -10,18 +10,27 @@ function epochTime () {
return ',"time":' + Date.now()
}

function unixTime () {
return ',"time":' + Math.round(Date.now() / 1000.0)
}
const unixTime = fastDate({
format: 'unix',
prefix: ',"time":',
suffix: ''
})

const utcTime = fastDate({
format: 'utc',
prefix: ',"time":"',
suffix: '"'
})

function utcTime () {
return ',"time": "' + fastDate() + '"'
function isoTime () {
return ',"time": "' + (new Date()).toISOString() + '"'
}

module.exports = {
nullTime: nullTime,
epochTime: epochTime,
unixTime: unixTime,
utcTime: utcTime,
isoTime: isoTime,
defaultTime: utcTime
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -78,7 +78,7 @@
"zuul": "^3.11.1"
},
"dependencies": {
"fast-date": "^2.0.0",
"fast-date": "^3.0.0",
"fast-json-parse": "^1.0.3",
"fast-safe-stringify": "^2.0.4",
"flatstr": "^1.0.5",
Expand Down

0 comments on commit d560a43

Please sign in to comment.