linux - Can I use curl real time minus sys and user to generally get total response time -
in linux shell script running time against curl request rest service.
assuming single thread, if take real time of result , subtract user , sys time remaining time considered aggregation of network latency , time service required complete request?
if not, there simple way network latency , time service required complete request linux shell?
reference:what 'real', 'user' , 'sys' mean in output of time(1)?
if using curl, simplest way details on request timings use -w/--write-out option.
you can format output include variables like:
time_appconnecttime, in seconds, took start until ssl/ssh/etc connect/handshake remote host completed. (added in 7.19.0)
time_connecttime, in seconds, took start until tcp connect remote host (or proxy) completed.
time_namelookuptime, in seconds, took start until name resolving completed.
time_pretransfertime, in seconds, took start until file transfer begin. includes pre-transfer commands , negotiations specific particular protocol(s) involved.
time_redirecttime, in seconds, took redirection steps include name lookup, connect, pretransfer , transfer before final transaction started. time_redirect shows complete execution time multiple redirections. (added in 7.12.3)
time_starttransfertime, in seconds, took start until first byte transferred. includes time_pretransfer , time server needed calculate result.
time_totaltotal time, in seconds, full operation lasted. time displayed millisecond resolution.
for example:
$ curl httpbin.org/ip -s -o output -w 'dns: %{time_namelookup} sec\nconnect: %{time_connect} sec\nuntil first byte: %{time_starttransfer} sec\ntotal: %{time_total} sec\n' dns: 0.061 sec connect: 0.297 sec until first byte: 0.502 sec total: 0.502 sec and answer direct question - no, subtracting process , process kernel time wall clock time not, in general, give network latency or response time. consider system many processes competing cpu: in case wall clock curl process can longer actual service response time.
Comments
Post a Comment