-
Notifications
You must be signed in to change notification settings - Fork 0
/
connector_perfomance.py
44 lines (37 loc) · 1.27 KB
/
connector_perfomance.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
import time
from worktory import InventoryManager
inventory = InventoryManager('inventory.yml')
connectors_result = {}
fh = open('results.txt', 'w')
for device in inventory.filter(mode='sync'):
connector = device.connection_manager.registry_name
print(f'\nStart collecting {device.name} with {connector}')
connectors_result[connector] = {
'times': [],
'failures': 0
}
for it in range(50):
try:
start = time.time()
device.connect()
output = device.parse("show version")
print(output)
device.disconnect()
end = time.time()
connectors_result[connector]['times'].append(end - start)
except Exception as e:
print(f"{connector} -- {e}")
connectors_result[connector]['failures'] += 1
print('\n\n')
for connector in connectors_result:
times = connectors_result[connector]['times']
total_time = sum(times)
mean_time = total_time/len(times)
min_time = min(times)
max_time = max(times)
fh.write(f"{connector};{times};{max_time};{min_time};{mean_time}\n")
print(f"Connector: {connector}:\n"
f"Max time: {max_time}\n"
f"Min time: {min_time}\n"
f"Mean time: {mean_time}\n\n")
fh.close()