-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark.py
More file actions
35 lines (30 loc) · 719 Bytes
/
benchmark.py
File metadata and controls
35 lines (30 loc) · 719 Bytes
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
from sre_parse import expand_template
from tracemalloc import start
from blinker import receiver_connected
import requests
import time
import os
from multiprocessing import Process, Value
received = Value('i', 0, lock=False)
IP = 'http://localhost'
PORT = '9000'
def print_received():
global receive
while True:
time.sleep(1)
print('Received %d data in one second' % received.value)
received.value = 0
def update_received():
global received
received.value = 0
while True:
r = requests.get(IP + ':' + PORT)
if r.status_code == 200:
received.value += 1
def main():
p1 = Process(target=print_received)
p2 = Process(target=update_received)
p1.start()
p2.start()
if __name__ == '__main__':
main()