Created
June 21, 2016 12:38
-
-
Save nicolargo/94d40a51153a46e1991dcc9ddb2cb344 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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