Node.js: get response time

How to find out URL response time?

I am using http.get() to create an HTTP GET request.

+6
source share
2 answers

There is no built-in function or value to get response time.

But you can easily get the value yourself.

 var http = require('http'); var start = new Date(); http.get({host: 'google.com', port: 80}, function(res) { console.log('Request took:', new Date() - start, 'ms'); }); 

EDIT

Since V8 also supports the new ES5 Date.now() , using this instead of new Date() would be a little cleaner.

+21
source share

If you are not looking for a software solution, download your friend and mine, Firefox with Firebug installed. When you call Firebug, select the "Net" tab and you will see the response time of all requests on the page. Hover over some time, and you will get a pop-up message about where the time has come - DNS lookup, timeout, etc.

0
source share

All Articles