--- db.py Thu Jun 15 02:10:41 2000 +++ db.py Mon Oct 9 18:06:53 2000 @@ -142,6 +142,12 @@ def __init__(self,connection): self.connection=connection + self.MYSQL_TIMING = 1 + if self.MYSQL_TIMING: + self.timinglog = open('/tmp/mysql_timing.log', 'w+') + if not self.timinglog: + print "Error: Can't open /tmp/mysql_timing.log for writing" + self.MYSQL_TIMING = None info=split(connection) if info and len(info) < 4: @@ -174,6 +180,7 @@ select_m=regex.compile('[\0- ]*select[\0- ]+', regex.casefold).match, ): + import time db=self.db try: queries=filter(None, map(strip,split(query_string, '\0'))) @@ -181,11 +188,22 @@ result=() desc=None for qs in queries: + if self.MYSQL_TIMING: + start_time = time.time() db.query(qs) + c=db.store_result() try: desc=c.describe() r=c.fetch_all_rows() + if self.MYSQL_TIMING: + end_time = time.time() + tot_time = end_time - start_time + tmpstr = "SQL Statement: " + qs + "\n" + self.timinglog.write(tmpstr) + tmpstr = "Execution Time: " + str(tot_time*1000) + " miliseconds (ms)\n\n" + self.timinglog.write(tmpstr) + self.timinglog.flush() except: r=None if not r: continue if result: