#!/usr/bin/env python
import MySQLdb, pp, time
import MySQLdb.cursors
conn = MySQLdb.connect (host = "192.168.1.254",user = "root",passwd = "000000",db = "test",cursorclass = MySQLdb.cursors.DictCursor)
cursor = conn.cursor()
#two=conn.cursor()
#two.execute ("select * from slevin")
sql="select * from slevin"
#row=two.fetchall()
ppservers = ("192.168.1.254",)
#ppservers = ("10.0.0.1",)
ncpus=2
job_server = pp.Server(ncpus, ppservers=ppservers)
#job1 = job_server.submit(sum_primes, (100,), (isprime,), ("math",))
def count(sql,n):
i=1
while i<=n:
cursor.execute(sql)
start_time = time.time()
job1 = job_server.submit(count, (sql,1000000,), (cursor.execute,), ("MySQLdb",))
print "Time elapsed: ", time.time() - start_time, "s"
cursor.close ()
conn.close ()
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |