The test case was modified from: myconyy appears to be roughly an order of magn1_slower than MySQLdb. Based on the test case, the performance comparison after psyco optimization is also added.
Test code:
#! /Usr/bin/env python
#-*-Coding: UTF-8 -*-
"Benchmark
"""
From mysql import connector
Import MySQLdb
Import time
Baseq = "SELECT * FROM url limit 10"
Def measure (func, * args, ** kw ):
Start = time. time ()
Result = func (* args, ** kw)
End = time. time ()
Return end-start, result
Def scansequential (iters, connect ):
For I in xrange (iters ):
If MySQLdb. connect = connect:
Conn = connect (host = 'localhost', port = 3306, user = 'aaa', passwd = '000000', db = 'test ')
Else:
Conn = connect (host = 'localhost', port = 3306, user = 'aaa', password = '000000', db = 'test ')
For I in xrange (5 ):
Curs = conn. cursor ()
Retval = curs.exe cute (baseq)
Orig_rowcount = curs. rowcount
Rows = curs. fetchall ()
Curs. close ()
Conn. close ()
Iters = 100
T, _ = measure (scansequential, iters, connector. Connect)
Print "myconyy", t
T, _ = measure (scansequential, iters, MySQLdb. connect)
Print "MySQLdb", t
Import psyco
Psyco. full ()
T, _ = measure (scansequential, iters, connector. Connect)
Print "myconyy with psyco", t
Obtain 10 rows of data:
Myconyy 2.53226113319
0.572678804398 MySQLdb
Myconyy with psyco 1.79596400261
Obtain 50 rows of data:
Myconyy 6.3902618885
1.56350803375 MySQLdb
Myconyy with psyco 4.51574015617
Obtain 100 rows of data:
Myconyy 11.1748549938
2.54134678841 MySQLdb
Myconyy with psyco 7.9241900444
Obviously, myconyy is five times slower than MySQLdb. This is a common problem in pure python implementation (weak). After psyco is added, the performance has improved, but there is still a 3x gap with MySQLdb.
However, with this pure python implementation, combined with asynchronous IO (non-blocking IO), data access can be completely non-blocking, so that it can meet stackless, eventlet, coroutine, diesel, tornado and other coroutine development.
^_^.