diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-06-03 15:54:46 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-06-03 15:54:46 +0200 |
commit | 1dded9849346000bf387101572fc9c05a59435b1 (patch) | |
tree | 05a482b271bc695e3ac0babf56b0e26925568e15 | |
parent | a531f185872495afa49f52ac84c1d3929113a692 (diff) | |
download | libuca-1dded9849346000bf387101572fc9c05a59435b1.tar.gz libuca-1dded9849346000bf387101572fc9c05a59435b1.tar.bz2 libuca-1dded9849346000bf387101572fc9c05a59435b1.tar.xz libuca-1dded9849346000bf387101572fc9c05a59435b1.zip |
tango: add stress test script
-rw-r--r-- | tango/stress-test.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tango/stress-test.py b/tango/stress-test.py new file mode 100644 index 0000000..2bb6dea --- /dev/null +++ b/tango/stress-test.py @@ -0,0 +1,52 @@ +import argparse +import PyTango +import sys +import time +import numpy as np +try: + import progressbar + HAVE_PROGRESSBAR = True +except ImportError: + HAVE_PROGRESSBAR = False + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('device', type=str, + help='TANGO device address') + parser.add_argument('-n', '--number', type=int, default=1000, + help='Number of frames to acquire') + + args = parser.parse_args() + + camera = PyTango.DeviceProxy(args.device) + camera.exposure_time = 0.0001 + camera.Start() + + start = time.time() + size = 0 + + if HAVE_PROGRESSBAR: + progress = progressbar.ProgressBar(max_value=args.number, redirect_stdout=True) + else: + progress = lambda x: x + print("Recording {} frames ...".format(args.number)) + + for i in progress(range(args.number)): + try: + frame = camera.image + except: + camera.Stop() + print("Failure after {} frames".format(i)) + sys.exit(0) + + size += frame.nbytes + + if HAVE_PROGRESSBAR: + progress.update(i) + + end = time.time() + camera.Stop() + + print("Bandwidth: {:.3f} MB/s".format(size / (end - start) / 1024. / 1024.)) |