Ref. https://stackoverflow.com/questions/18106825/nodejs-request-library-get-the-response-time
The request library can do timing for you (docs):
request.get({ url : 'http://example.com', time : true },function(err, response){ console.log('Request time in ms', response.elapsedTime); });
As the question implies, you could get issues with the approach of starting a timer, calling request then stopping the timer in the callback:
var start = new Date(); request.get('http://example.com', function(err, response){ // NOT GOOD console.log('Request time plus 5 seconds', new Date() - start); }); require('sleep').sleep(5); // time-consuming synchronous action
'Programming > JavaScript, Node.js' 카테고리의 다른 글
Node Version Manager (0) | 2021.01.15 |
---|---|
What is the .NPMRC file for? (0) | 2020.08.11 |
Public, Private, and Protected Scope in JavaScript (0) | 2020.08.07 |
How to uninstall an npm Node package, locally or globally (0) | 2020.08.06 |
Object.keys, values, entries (0) | 2020.08.05 |
댓글