1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
from __future__ import print_function
import sys
import time
import epics
from pvnames import motor_list
pvnames= []
for a in ('VAL','RBV','DVAL', 'RVAL','LLM','HLM','DIR','OFF',
'FOFF','VELO','VBAS','ACCL','DESC','MRES'):
for m in motor_list:
pvnames.append("%s.%s" %(m,a))
print( pvnames)
def testconnect(pvnames,connect=True):
t0 = time.time()
pvlist= []
for pvname in pvnames:
x = epics.PV(pvname)
if connect:
x.connect()
pvlist.append(x)
for x in pvlist:
x.get()
dt = time.time()-t0
# for x in pvlist:
# x.get()
sys.stdout.write('===Connect with PV(connect=%s) to %i pvs\n' % (connect, len(pvlist)))
sys.stdout.write(' Total Time = %.4f s, Time per PV = %.1f ms\n' % ( dt, 1000.*dt/len(pvlist)))
sys.stdout.write( """
Test connection time for many PVs.
With:
pvs = []
for pvn in pvnames:
x = epics.PV(pvn)
x.connect()
pvs.append(x)
for x in pvs: x.get()
connection takes 30ms per PV
With
pvs = []
for pvname in pvlist:
x = PV(pvname)
pvs.append(x)
for x in pvs: x.get()
connection takes less than 8ms per PV.
""")
testconnect(pvnames, False)
epics.ca._cache = {}
testconnect(pvnames, True)
print( 'Done')
|