Changeset 2702 for pykota

Show
Ignore:
Timestamp:
02/17/06 21:58:51 (19 years ago)
Author:
jerome
Message:

Now displays the number of entries per second.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/tests/filldb.py

    r2683 r2702  
    99import time 
    1010 
     11def showTiming(number, before) : 
     12    """Displays timing information.""" 
     13    elapsed = time.time() - before 
     14    persecond = int(float(number) / elapsed) 
     15    sys.stdout.write("\nTime elapsed : %.2f seconds (%i entries per second)\n\n" % (elapsed, persecond)) 
     16     
    1117def createBillingCodes(number) : 
    1218    """Creates a number of billing codes.""" 
     
    2026    before = time.time() 
    2127    os.system('pkbcodes --arguments arguments.list')  
    22     after = time.time() 
    23     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     28    showTiming(number, before) 
    2429 
    25 def deleteBillingCodes() : 
     30def deleteBillingCodes(number) : 
    2631    """Deletes all test billing codes.""" 
    2732    sys.stdout.write("Deleting billing codes...\n") 
    2833    before = time.time() 
    2934    os.system('pkbcodes --delete "test-billingcode-*"')  
    30     after = time.time() 
    31     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     35    showTiming(number, before) 
    3236     
    3337def createPrinters(number) : 
     
    4246    before = time.time() 
    4347    os.system('pkprinters --arguments arguments.list')  
    44     after = time.time() 
    45     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     48    showTiming(number, before) 
    4649 
    47 def deletePrinters() : 
     50def deletePrinters(number) : 
    4851    """Deletes all test printers.""" 
    4952    sys.stdout.write("Deleting printers...\n") 
    5053    before = time.time() 
    5154    os.system('pkprinters --delete "test-printer-*"')  
    52     after = time.time() 
    53     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     55    showTiming(number, before) 
    5456     
    5557def createUsers(number) : 
     
    6466    before = time.time() 
    6567    os.system('edpykota --arguments arguments.list')  
    66     after = time.time() 
    67     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     68    showTiming(number, before) 
    6869 
    69 def deleteUsers() : 
     70def deleteUsers(number) : 
    7071    """Deletes all test users.""" 
    7172    sys.stdout.write("Deleting users...\n") 
    7273    before = time.time() 
    7374    os.system('edpykota --delete "test-user-*"')  
    74     after = time.time() 
    75     sys.stdout.write("\nTime elapsed : %.2f seconds\n\n" % (after - before)) 
     75    showTiming(number, before) 
    7676     
    7777if __name__ == "__main__" :     
     
    8989            createUsers(nbusers) 
    9090        if nbbillingcodes :     
    91             deleteBillingCodes() 
     91            deleteBillingCodes(nbbillingcodes) 
    9292        if nbusers :     
    93             deleteUsers()           # NB : either this one or the one below 
     93            deleteUsers(nbusers)           # NB : either this one or the one below 
    9494        if nbprinters :     
    95             deletePrinters()        # also delete user print quota entries. 
     95            deletePrinters(nbprinters)        # also delete user print quota entries. 
    9696        os.remove("arguments.list") 
    9797