forked from freespace/pyAPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.py
47 lines (37 loc) · 1.12 KB
/
bench.py
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
#!/usr/bin/env python
"""
Usage: python bench.py
Performs simply benchmarks on how long it takes to list devices, open a device
and performing a status query
"""
from __future__ import absolute_import
from __future__ import print_function
import pylibftdi
import pyAPT
import time
def main(args):
print('Looking for APT controllers')
drv = pylibftdi.Driver()
st = time.time()
controllers = drv.list_devices()
print('\tlist_devices:',time.time()-st)
if controllers:
for con in controllers:
print('Found %s %s S/N: %s'%con)
st = time.time()
with pyAPT.MTS50(serial_number=con[2]) as con:
print('\topen:',time.time()-st)
st = time.time()
status = con.status()
print('\tstatus:',time.time()-st)
print('\tController status:')
print('\t\tPosition: %.2fmm'%(status.position))
print('\t\tVelocity: %.2fmm'%(status.velocity))
print('\t\tStatus:',status.flag_strings())
return 0
else:
print('\tNo APT controllers found. Maybe you need to specify a PID')
return 1
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))