javascript - node.js process.hrtime in asynchronous server? -
i create http server using http.createserver(onrequest)
, want measure time needed make response.
currently, in onrequest
handler do:
var start = process.hrtime(); response.on('end', function (){ console.log('time respond', process.hrtime(start)); }); // call various asynchronous functions , send them 'response' object. 1 of them response.end()
i'm worried if work fine when bunch of requests comes instantly, or asynchronism break it/mix-up times?
the variable in closure scope of onrequest
handler function it'll work way expect (assuming process.hrtime
want).
Comments
Post a Comment