Skip to content

Instantly share code, notes, and snippets.

@Whissi
Forked from stickystyle/MySQL network benchmark
Last active August 29, 2015 14:20
Show Gist options
  • Save Whissi/59c24b2702423ad8a276 to your computer and use it in GitHub Desktop.
Save Whissi/59c24b2702423ad8a276 to your computer and use it in GitHub Desktop.
#!/bin/env python
import timeit
loops = 1000
setup = """
import MySQLdb
db = MySQLdb.connect(host="remotedb.example.com",
read_default_file="/root/.my.cnf",
charset = "utf8", use_unicode = True)
c = db.cursor()
"""
stmt = 'c.execute("SELECT 1")'
t = timeit.Timer(stmt, setup)
total_time = t.timeit(number=loops)
print "Total loops: {}".format(loops)
print "Total time: {}".format(total_time)
print "Avg time per loop: {}".format(total_time / loops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment