Changeset 2742 for pykota

Show
Ignore:
Timestamp:
02/21/06 19:42:25 (19 years ago)
Author:
jerome
Message:

Now ouputs some timing info even when debug:no is used.
Also uses psyco, which halves the time spent before deletion begins.
The storagecaching:yes directive is not at fault.

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r2739 r2742  
    2929import pwd 
    3030import grp 
     31import time 
    3132from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 
    3233from pykota.config import PyKotaConfigError 
     
    162163        if options["delete"] :     
    163164            self.display("%s...\n" % _("Deletion")) 
    164             printers = self.storage.getMatchingPrinters(options["printer"]) 
    165             entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 
    166             nbtotal = len(entries) * len(printers) 
    167             i = 0 
    168             for printer in printers : 
    169                 for entry in entries : 
    170                     pqentry = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer) 
    171                     if pqentry.Exists : 
    172                         pqentry.delete() 
    173                     i += 1     
    174                     percent = 100.0 * float(i) / float(nbtotal) 
    175                     self.display("\r%.02f%%" % percent) 
     165            #printers = self.storage.getMatchingPrinters(options["printer"]) 
     166            #entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 
     167            before = time.time() 
     168            (printers, entries, pqentries) = getattr(self.storage, "getPrinters%ssAndPQuotas" % suffix)(printernames, names) 
     169            after = time.time() 
     170            self.printInfo("Data extraction took %.4f seconds" % (after - before)) 
     171            nbtotal = len(pqentries) 
     172            for i in range(nbtotal) : 
     173                (pqkey, pqentry) = pqentries.popitem() 
     174                if pqentry.Exists : 
     175                    pqentry.delete() 
     176                percent = 100.0 * float(i) / float(nbtotal) 
     177                self.display("\r%.02f%%" % percent) 
    176178        else : 
    177179            if not names : 
     
    317319                      
    318320if __name__ == "__main__" :  
     321    try :  
     322       import psyco 
     323       psyco.profile() 
     324    except :    
     325       pass 
    319326    retcode = 0 
    320327    try : 
  • pykota/trunk/pykota/storages/sql.py

    r2735 r2742  
    467467        users = {} 
    468468        upquotas = {} 
     469        import time 
     470        before = time.time() 
    469471        result = self.doSearch("SELECT users.id AS uid, users.description AS udesc, printers.id AS pid, printers.description AS pdesc, printers.maxjobsize AS pmaxjobsize, userpquota.id AS upqid, userpquota.maxjobsize AS upqmaxjobsize, users.*, printers.*, userpquota.* FROM users, printers, userpquota WHERE users.id=userpquota.userid AND printers.id=userpquota.printerid;") 
     472        after = time.time() 
     473        self.tool.printInfo("SELECT took %.4f seconds." % (after - before)) 
    470474        if result : 
    471475            for record in result :