Skip to content

Commit

Permalink
Merge eaeae06 into 9805311
Browse files Browse the repository at this point in the history
  • Loading branch information
motss committed Apr 22, 2017
2 parents 9805311 + eaeae06 commit a798498
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ app.use((req, res, next) => {
next()
})
app.use((req, res, next) => {
// All timings should be in milliseconds (s). See issue #9 (https://github.com/yosuke-furukawa/server-timing/issues/9).
res.setMetric('db', 100.0, "Database metric")
res.setMetric('api', 200.0, "HTTP/API metric")
res.setMetric('cache', 300.0, "cache metric")
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function serverTiming (options) {
onHeaders(res, () => {
if (opts.total) {
const diff = process.hrtime(startAt)
const timeSec = (diff[0] + diff[1] * 1e-9)
const timeSec = (diff[0] * 1E3) + (diff[1] * 1e-6)
headers.push(`total=${timeSec}; "Total Response Time"`)
}
timer.clear()
Expand Down
2 changes: 1 addition & 1 deletion timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Timer {
return console.warn(`No such name ${name}`)
}
const duration = process.hrtime(timeObj.start)
const value = (duration[0] + duration[1] * 1e-9)
const value = (duration[0] * 1E3) + (duration[1] * 1e-6)
timeObj.value = value
this._times.delete(name)
return timeObj
Expand Down

0 comments on commit a798498

Please sign in to comment.