00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2002 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 """Test script for commanding 00011 Contents: 00012 Sample script for testing write command throughput 00013 """ 00014 __facility__ = "Online" 00015 __abstract__ = "Test script for testing write command throughput" 00016 __author__ = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST I&T/Online" 00017 __date__ = ("$Date: 2005/03/21 18:37:28 $").split(' ')[1] 00018 __version__ = "$Revision: 2.3 $" 00019 __release__ = "$Name: R04-12-00 $" 00020 __credits__ = "SLAC" 00021 00022 import LATTE.copyright_SLAC 00023 00024 from LATTE.client.gOptions import Options 00025 from LATTE.client.gCmdCli import CmdCli 00026 from LATTE.database.gLAT import GLAT 00027 00028 import os 00029 import time 00030 00031 00032 def test(cmd=None, disconnectOnExit=True): 00033 global tem, glt 00034 00035 options = Options(['server', 'schema']) 00036 try: 00037 options.parse() 00038 except Exception, msg: 00039 options.usage(str(msg)) 00040 return 00041 00042 if cmd == None: 00043 cmd = CmdCli() 00044 cmd.connect(options.server) 00045 passed = True 00046 00047 try: 00048 lat = GLAT(cmd) 00049 00050 lat.readSchema(options.schema) 00051 00052 # Get a TEM instance 00053 if lat.TEMcnt() == 1: 00054 tem = lat.TEM[lat.TEM.keys()[0]] 00055 elif lat.TEMcnt() > 1: 00056 tem = lat.TEM.all() 00057 00058 cnt = 10000 00059 start = time.time() 00060 for i in xrange(cnt): 00061 tem.COMMAND_RESPONSE = 1234 # clear TEM stats reg 00062 #cmd.gTEMload(0, 3, 1234) # ~18500 writes/second 00063 #if i % 1000 == 0: print i 00064 end = time.time() 00065 et = end-start 00066 if et == 0: et = 0.000001 00067 print "Finished in %f seconds (%.1f write commands/second)" %(et, (cnt/et)) 00068 00069 except Exception, e: 00070 print "Exception occurred: ", e 00071 passed = False 00072 00073 if passed: 00074 print "test_cmd: PASSED" 00075 else: 00076 print "test_cmd: FAILED" 00077 00078 if disconnectOnExit: 00079 cmd.disconnect() 00080 00081 if __name__ == '__main__': 00082 test() 00083 00084 # RiC 6/16/04: Measured 10298 +/- ~150 writes/sec on D600 laptop (1.7 GHz, 00085 # 600 MHz bus, 1 GB) in local mode with prints commented out, 00086 # without cmdRelayer. 00087 # RiC 6/17/04: Measured 5841 +- ~50 writes/sec on same setup as above but with 00088 # SocketServer based cmdRelayer.