Mercurial > code > home > repos > light9
comparison bin/collector_loadtest.py @ 2078:2c48e92ad5d3
make loadtest real enough to cause numbers to change on collector's web view
author | drewp@bigasterisk.com |
---|---|
date | Tue, 24 May 2022 01:21:32 -0700 |
parents | d5f1cc9615af |
children |
comparison
equal
deleted
inserted
replaced
2077:46a8f5a8a4dd | 2078:2c48e92ad5d3 |
---|---|
1 #!bin/python | 1 #!bin/python |
2 import asyncio | 2 import asyncio |
3 import logging | 3 import logging |
4 import random | |
5 from rdflib import URIRef | |
4 import time | 6 import time |
5 from typing import cast | |
6 | 7 |
7 from light9.collector.collector_client_asyncio import sendToCollector | 8 from light9.collector.collector_client_asyncio import sendToCollector |
8 from light9.effect.settings import DeviceSettings | 9 from light9.effect.settings import DeviceSettings |
9 from light9.namespaces import DEV, L9 | 10 from light9.namespaces import DEV, L9 |
10 from light9.run_local import log | 11 from light9.run_local import log |
13 | 14 |
14 | 15 |
15 async def loadTest(): | 16 async def loadTest(): |
16 print("scheduling loadtest") | 17 print("scheduling loadtest") |
17 n = 200000 | 18 n = 200000 |
18 period=1 | 19 period=.02 |
19 times = [] | 20 times = [] |
20 session = "loadtest%s" % time.time() | 21 session = "loadtest%s" % time.time() |
21 for i in range(n): | 22 for i in range(n): |
22 if i % 100 == 0: | 23 if i % 100 == 0: |
23 log.info('sendToCollector %s', i) | 24 log.info('sendToCollector %s', i) |
26 "http://localhost:8202/", | 27 "http://localhost:8202/", |
27 session, | 28 session, |
28 DeviceSettings( | 29 DeviceSettings( |
29 graph=None, | 30 graph=None, |
30 settingsList=[ | 31 settingsList=[ |
31 [DEV["backlight1"], L9["color"], "#ffffff"], # | 32 # [DEV["backlight1"], L9["color"], "#ffffff"], # |
32 [DEV["backlight2"], L9["color"], "#ffffff"], | 33 # [DEV["backlight2"], L9["color"], "#ffffff"], |
33 [DEV["backlight3"], L9["color"], "#ffffff"], | 34 # [DEV["backlight3"], L9["color"], "#ffffff"], |
34 [DEV["backlight4"], L9["color"], "#ffffff"], | 35 # [DEV["backlight4"], L9["color"], "#ffffff"], |
35 [DEV["backlight5"], L9["color"], "#ffffff"], | 36 # [DEV["backlight5"], L9["color"], "#ffffff"], |
36 [DEV["down2"], L9["color"], "#ffffff"], | 37 # [DEV["down2"], L9["color"], "#ffffff"], |
37 [DEV["down3"], L9["color"], "#ffffff"], | 38 # [DEV["down3"], L9["color"], "#ffffff"], |
38 [DEV["down4"], L9["color"], "#ffffff"], | 39 # [DEV["down4"], L9["color"], "#ffffff"], |
39 [DEV["houseSide"], L9["level"], .8], | 40 [URIRef('http://light9.bigasterisk.com/theater/skyline/device/down1'), L9["brightness"], random.random()], |
40 [DEV["backlight5"], L9["uv"], 0.011] | 41 [DEV["backlight5"], L9["uv"], 0.011] |
41 ])) | 42 ])) |
42 times.append(time.time() - start) | 43 times.append(time.time() - start) |
43 await asyncio.sleep(period) | 44 await asyncio.sleep(period) |
44 | 45 |