Not sure if this chart gives you a better understanding of performance.timing.
For your question:
I am having 5 server call for web page load, performance.timing object
is generated based on all the 5 server calls or based on the 5th
server call(last call).
The answer is: performance.timing
is generated based on all requests and responses (but not including the ajax ones).
For the sample connection speed calculation script you gave, I guess the below one is better.
var duration = performance.timing.responseEnd - performance.timing.responseStart;
The reason is: the duration from navigationStart
to responseEnd
includes DNS timing which does not transfer any data from server to client.
Please refer to https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html for the definition of timings.