Commit f901a1bb authored by Alan Mitchell's avatar Alan Mitchell
Browse files

More accurate Post Rate Calc.

parent aad6ab4f
......@@ -112,20 +112,22 @@ if __name__ == '__main__':
thread_count = int(args[1]) if len(args)>=2 else 5
rdg_delay = float(args[2]) if len(args)>=3 else 0.0
TOT_POST_TIME = 5.0 # seconds
POST_SLEEP = 5.0 # seconds
posters = []
tstart = time.time()
for i in range(thread_count):
sensor_id = 'test_%03d' % i
poster = ReadingPoster(sensor_id, rdg_delay)
posters.append(poster)
poster.start()
time.sleep(TOT_POST_TIME)
time.sleep(POST_SLEEP)
t_elapsed = time.time() - tstart
total_reads = 0
for p in posters:
p.stop_posting()
total_reads += p.reading_count
print '%.1f posts / second' % (total_reads / TOT_POST_TIME)
time.sleep(rdg_delay*1.1) # wait for threads to exit cleanly?
print '%.1f posts / second' % (total_reads / t_elapsed)
time.sleep(rdg_delay*1.2) # wait for threads to exit cleanly?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment