Mercurial > code > home > repos > light9
annotate bin/collector_loadtest.py @ 2346:ab893f0630b7
try sending midi events to graph more often
author | drewp@bigasterisk.com |
---|---|
date | Sat, 03 Jun 2023 14:51:44 -0700 |
parents | 2c48e92ad5d3 |
children |
rev | line source |
---|---|
2070
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
1 #!bin/python |
2072 | 2 import asyncio |
2070
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
3 import logging |
2078
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
4 import random |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
5 from rdflib import URIRef |
2070
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
6 import time |
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
7 |
2072 | 8 from light9.collector.collector_client_asyncio import sendToCollector |
2070
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
9 from light9.effect.settings import DeviceSettings |
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
10 from light9.namespaces import DEV, L9 |
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
11 from light9.run_local import log |
2951a690f1ba
collector takes requests from bin/collector_loadtest.py
drewp@bigasterisk.com
parents:
1866
diff
changeset
|
12 |
1493
4294ed82ee16
move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though
drewp@bigasterisk.com
parents:
diff
changeset
|
13 log.setLevel(logging.DEBUG) |
1858 | 14 |
15 | |
2072 | 16 async def loadTest(): |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
17 print("scheduling loadtest") |
2072 | 18 n = 200000 |
2078
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
19 period=.02 |
2072 | 20 times = [] |
1493
4294ed82ee16
move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though
drewp@bigasterisk.com
parents:
diff
changeset
|
21 session = "loadtest%s" % time.time() |
4294ed82ee16
move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though
drewp@bigasterisk.com
parents:
diff
changeset
|
22 for i in range(n): |
2072 | 23 if i % 100 == 0: |
24 log.info('sendToCollector %s', i) | |
25 start = time.time() | |
26 await sendToCollector( | |
27 "http://localhost:8202/", | |
28 session, | |
29 DeviceSettings( | |
30 graph=None, | |
31 settingsList=[ | |
2078
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
32 # [DEV["backlight1"], L9["color"], "#ffffff"], # |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
33 # [DEV["backlight2"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
34 # [DEV["backlight3"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
35 # [DEV["backlight4"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
36 # [DEV["backlight5"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
37 # [DEV["down2"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
38 # [DEV["down3"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
39 # [DEV["down4"], L9["color"], "#ffffff"], |
2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
drewp@bigasterisk.com
parents:
2072
diff
changeset
|
40 [URIRef('http://light9.bigasterisk.com/theater/skyline/device/down1'), L9["brightness"], random.random()], |
2072 | 41 [DEV["backlight5"], L9["uv"], 0.011] |
42 ])) | |
43 times.append(time.time() - start) | |
44 await asyncio.sleep(period) | |
1858 | 45 |
2072 | 46 print("loadtest done") |
47 with open('/tmp/times', 'w') as f: | |
48 f.write(''.join('%s\n' % t for t in times)) | |
1493
4294ed82ee16
move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though
drewp@bigasterisk.com
parents:
diff
changeset
|
49 |
1858 | 50 |
1493
4294ed82ee16
move collector_loadtest and arrange for collector to be able to run the test itself, but that last part isn't working. you can run collector and collector_loadtest in two shells, though
drewp@bigasterisk.com
parents:
diff
changeset
|
51 if __name__ == '__main__': |
2072 | 52 asyncio.run(loadTest()) |