Simple performance test comparison between myconyy, myconyy + psyco and MySQLdb

Source: Internet
Author: User

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.

^_^.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.