I can use the time command to measure the time some command takes:

time node -e ""
node -e ""  0.06s user 0.01s system 92% cpu 0.076 total

Is there a similar way to measure a command's network traffic (the bandwidth it used, the hosts it sent requests to, etc)? What is the best solution for this use case?

  • 1
    Related - duplicate? unix.stackexchange.com/q/375387/117549
    – Jeff Schaller
    Commented Aug 1, 2020 at 1:04
  • Read man time. Will the socket reads/writes (%r, %s) help?
    – waltinator
    Commented Aug 1, 2020 at 19:40
  • 1
    Tracking the hosts accesses would require capturing outgoing network packets. Not easy.
    – waltinator
    Commented Aug 1, 2020 at 19:43
  • @waltinator I don't see those flags on macOS's time.
    – HappyFace
    Commented Aug 1, 2020 at 19:51
  • this can be considered as a no-sense because network traffic will vary again and again doing routing doing retries & so on so measurement by "time" is just a very bad indicator ; you might prefer a traffic analysis tool or a monitor tool or trying to work around asynchronously as @waltinator said from capturing output. at worst just keep on the ping or traceroute commands
    – francois P
    Commented Aug 2, 2020 at 20:14


You must log in to answer this question.

Browse other questions tagged .