Skip to content

Instantly share code, notes, and snippets.

@methane
Last active March 17, 2016 08:42
Show Gist options
  • Save methane/b5813669e9dbd0c321bd to your computer and use it in GitHub Desktop.
Save methane/b5813669e9dbd0c321bd to your computer and use it in GitHub Desktop.
Quick benchmark on PyMySQL
time[sec]
CPython 3.4.2(6f78fcb) 20.5
CPython 3.4.2(a724607) 14.2
PyPy 2.5 (6f78fcb) 3.4
PyPy 2.5 (a724607) 3.1
CPython (mysqlclient) 2.8

Dataset is "world database (innodb)". It is deployed on here

import MySQLdb
import timeit
conn = MySQLdb.connect(user='root', db='test_pymysql', charset='utf8')
def load_city():
cur = conn.cursor()
cur.execute('SELECT * FROM City LIMIT 1000')
cur.fetchall()
cur.close()
print(timeit.timeit(load_city, number=1000))
import pymysql
import timeit
conn = pymysql.connect(user='root', db='test_pymysql', charset='utf8')
def load_city():
cur = conn.cursor()
cur.execute('SELECT * FROM City LIMIT 1000')
cur.fetchall()
cur.close()
print(timeit.timeit(load_city, number=1000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment