Skip to content

Instantly share code, notes, and snippets.

@johnchen902
Created June 25, 2017 16:56
Show Gist options
  • Save johnchen902/7408318d243da70ebb90355f83c5636f to your computer and use it in GitHub Desktop.
Save johnchen902/7408318d243da70ebb90355f83c5636f to your computer and use it in GitHub Desktop.
Network namespace timing
#!/usr/bin/env bash
TIMEFORMAT="%R"
sumt1=0
sumt2=0
for ((i=1; i<=10; i++)); do
echo -ne $i\\r
sumt1=$(bc <<< "$sumt1 + $(time (unshare -n true) 2>&1)")
sumt2=$(bc <<< "$sumt2 + $(time (unshare -n true) 2>&1)")
sleep $(bc <<< "scale=3; ($sumt1 + $sumt2) / $i * 2")
done
echo sumt1 = $sumt1, sumt2 = $sumt2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment