annotate bin/collector_loadtest.py @ 1866:3c523c71da29

pyflakes cleanups and some refactors Ignore-this: f7372e678699175feb4e628eee3d768c
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 25 May 2019 12:10:51 +0000
parents f066d6e874db
children 2951a690f1ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
1 import sys
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
2 sys.path.append('bin')
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
3 from run_local import log
1866
3c523c71da29 pyflakes cleanups and some refactors
Drew Perttula <drewp@bigasterisk.com>
parents: 1859
diff changeset
4 from light9.collector.collector_client import sendToCollector
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
5 from light9.namespaces import L9, DEV
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
6 from twisted.internet import reactor
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
7 import 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
8 import logging
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
9 log.setLevel(logging.DEBUG)
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
10
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
11
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
12 def loadTest():
1859
f066d6e874db 2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents: 1858
diff changeset
13 print("scheduling loadtest")
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
14 n = 2500
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
15 times = [None] * n
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
16 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
17 offset = 0
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
18 for i in range(n):
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
19
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
20 def send(i):
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 if i % 100 == 0:
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 log.info('sendToCollector %s', i)
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
23 d = sendToCollector("http://localhost:999999/", session,
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
24 [[DEV["backlight1"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
25 [DEV["backlight2"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
26 [DEV["backlight3"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
27 [DEV["backlight4"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
28 [DEV["backlight5"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
29 [DEV["down2"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
30 [DEV["down3"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
31 [DEV["down4"], L9["color"], "#ffffff"],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
32 [DEV["houseSide"], L9["level"], .8],
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
33 [DEV["backlight5"], L9["uv"], 0.011]])
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
34
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
35 def ontime(dt, i=i):
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
36 times[i] = dt
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
37
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
38 d.addCallback(ontime)
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
39
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
40 reactor.callLater(offset, send, i)
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
41 offset += .002
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
42
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
43 def done():
1859
f066d6e874db 2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents: 1858
diff changeset
44 print("loadtest done")
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
45 with open('/tmp/times', 'w') as f:
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
46 f.write(''.join('%s\n' % t for t in times))
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
47 reactor.stop()
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
48
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
49 reactor.callLater(offset + .5, done)
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
50 reactor.run()
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
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 1830
diff changeset
52
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
53 if __name__ == '__main__':
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
54 loadTest()