Skip to content

Instantly share code, notes, and snippets.

@likejazz
Created July 6, 2019 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likejazz/d7f5ad29d2cc82290de9f2779ac1b546 to your computer and use it in GitHub Desktop.
Save likejazz/d7f5ad29d2cc82290de9f2779ac1b546 to your computer and use it in GitHub Desktop.
Analyzing Redis PING performance
import time
import redis
for i in range(10):
start_time = time.time()
try:
conn = redis.StrictRedis(
host='xxx',
port=6379,
db=0)
conn.ping()
except Exception as ex:
print('Error:', ex)
exit('Failed to connect, terminating.')
elapsed_time = float("{0:.2f}".format((time.time() - start_time) * 1000))
if elapsed_time > 3:
print(int(time.time()), elapsed_time)
# $ while true; do python ping.py; sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment