Skip to content

Instantly share code, notes, and snippets.

@nicolargo
Created June 21, 2016 12:38
Show Gist options
  • Save nicolargo/94d40a51153a46e1991dcc9ddb2cb344 to your computer and use it in GitHub Desktop.
Save nicolargo/94d40a51153a46e1991dcc9ddb2cb344 to your computer and use it in GitHub Desktop.
from datetime import datetime
import subprocess
import os
def foo(c):
fnull = open(os.devnull, 'w')
d1 = datetime.now()
subprocess.check_call(c, stdout=fnull, stderr=fnull, close_fds=True)
return (datetime.now() - d1).total_seconds()
print(foo(['ping', '-c', '1', '192.168.176.1']) * 1000.0)
print(foo(['ping', '-c', '1', '212.27.48.10']) * 1000.0)
print(foo(['ping', '-c', '1', '216.58.208.228']) * 1000.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment