Python Forum
Get average of multiple threads
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get average of multiple threads
#1
Hi,
Is there a way to get the average of all the requests. I am able to get the response time per execution as below(running as a loop). But is there a way to sum all of these and get the average?

Output:
Thread 0
Thread 1
request: 1 Status: 200OK ResponseTime: 0.003963258999999941
request: 0 Status: 200OK ResponseTime: 0.005142219999999975
Thread 0
Thread 1
request: 0 Status: 200OK ResponseTime: 0.004329180999999904
request: 1 Status: 200OK ResponseTime: 0.004248067999999994

I basically want to get the get the average of all the 4 entries above. NOTE: i am using
start = time.process_time() & request_time = time.process_time() - start to get the response time.
Thanks!!
Reply
#2
#Just before starting threads
thread_times = []
start_time = process_time()

#In each thread
thread_times.append(process_time() - start_time)

#When all are done
print('Average time =', mean(thread_times))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to separate a loop across multiple threads stylingpat 0 1,651 May-05-2021, 05:21 PM
Last Post: stylingpat
  stop multiple threads jeuvrey 5 3,328 Nov-15-2018, 01:34 PM
Last Post: jeuvrey
  Quitting multiple threads MuntyScruntfundle 3 2,616 Oct-17-2018, 05:14 AM
Last Post: volcano63
  How to run multiple threads properly cyberion1985 6 5,775 Dec-29-2017, 09:45 AM
Last Post: cyberion1985

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020