Measuring http request time using node.js

I am using node.js to send an HTTP request. I have a requirement to measure how long it took.

start = getTime()
http.send(function(data) {end=getTime()})

If I call getTime inside the HTTP response callback, there is a risk that my callback will not be called immediately when the response returns due to other events in the queue. Such a risk also exists if I use regular java or C # synchronous code for this task, since perhaps another thread has attracted attention in front of me.

start = getTime()
http.send()
end=getTime()

How does node.js compare with another (synchronous) platform - does this make my chance for a good measure better or worse?

+5
source share
1 answer

Great observations!

Theory:

-, , :

  • , http, , - node.

  • /, - .

  • / , , - / /.

  • , - / .

  • / : socket [http implementation].

:

Noe (1), Java/# . node -, , , . , , , , , , - , . - (2) - (5). , , , , , . , , , , .

, Java, - node, Java, , node .

, .

+1

All Articles