Skip to content

Commit

Permalink
test bandwidth
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiionutdamian committed Feb 19, 2024
1 parent 26231f7 commit b5bbd1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion labs/labs-internal/emqx/app/src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from paho.mqtt import client as mqttc
from paho.mqtt import __version__ as mqtt_version

__VER__ = '0.0.1'
__VER__ = '0.1.2'



Expand Down
19 changes: 17 additions & 2 deletions labs/labs-internal/emqx/app/src/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,25 @@ def on_message(self, client, userdata, msg, *args, **kwargs):

def display_stats(self, ):
"""Periodically display message stats."""
start = time.time()
while True:
good, bad = 0, 0
counter = 0
if len(self.messages) == 0:
time.sleep(1)
start = time.time()
continue
for sender, sum_ in self.messages.items():
self.P("----------------------------------------")
self.P(f"{sender} -> sum -> {sum_} (id: {self.counters[sender]})")
if sum_ == self.counters[sender]:
good +=1
else:
bad += 1
counter += self.counters[sender]
msg = "Stats: {} senders, {} stable, {} unstable, {:.0f} msgs/sec".format(
len(self.messages),
good, bad,
counter/(time.time()-start))
self.P(msg)
time.sleep(10) # Adjust as necessary
return

Expand Down

0 comments on commit b5bbd1c

Please sign in to comment.