X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Ftools%2Fodl-mdsal-clustering-tests%2Fclustering-performance-test%2Finventory_perf.py;h=2a4cfa925df3a1286a3975ad447e314e7bcb0781;hb=072f6e3a8d1bdf8f4c663843589c22d93ba07791;hp=c7582a0bed2c1fc142359a79d49bfbc3fc76bc90;hpb=ef206fd7458a5d3c3b1942767b4cb9cecb438bd2;p=integration%2Ftest.git diff --git a/test/tools/odl-mdsal-clustering-tests/clustering-performance-test/inventory_perf.py b/test/tools/odl-mdsal-clustering-tests/clustering-performance-test/inventory_perf.py index c7582a0bed..2a4cfa925d 100644 --- a/test/tools/odl-mdsal-clustering-tests/clustering-performance-test/inventory_perf.py +++ b/test/tools/odl-mdsal-clustering-tests/clustering-performance-test/inventory_perf.py @@ -8,10 +8,12 @@ import requests import time import threading + class Counter(object): def __init__(self, start=0): self.lock = threading.Lock() self.value = start + def increment(self, value=1): self.lock.acquire() try: @@ -54,6 +56,15 @@ print_lock = threading.Lock() def get_inventory(tnum, url, hdrs, rnum, cond): + """ + + :param tnum: + :param url: + :param hdrs: + :param rnum: + :param cond: + :return: + """ total_len = float(0) results = {} @@ -63,7 +74,7 @@ def get_inventory(tnum, url, hdrs, rnum, cond): s = requests.Session() with Timer() as t: for i in range(rnum): - r = s.get(url, headers=hdrs, stream=False ) + r = s.get(url, headers=hdrs, stream=False) total_len += len(r.content) try: @@ -116,7 +127,7 @@ if __name__ == "__main__": for i in range(nthreads): t = threading.Thread(target=get_inventory, - args=(i,url, getheaders, int(in_args.requests), cond)) + args=(i, url, getheaders, int(in_args.requests), cond)) threads.append(t) t.start() @@ -127,7 +138,7 @@ if __name__ == "__main__": finished = finished + 1 print '\nAggregate requests: %d, Aggregate requests/sec: %.2f' % (total_requests.value, - total_req_rate.value) + total_req_rate.value) print 'Aggregate Volume: %.2f MB, Aggregate Rate: %.2f MByte/s' % (total_mbytes.value, total_mb_rate.value)