Python Forum
How to measure execution time of a multithread loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to measure execution time of a multithread loop
#1
I have a small app that does work on about 100 loops each on a new thread. How can I measure the total execution time from the point where the app started to run to the point where the last thread completed?

If I do a print(endtime - starttime) after the last loop, the threads are still running for about 10 seconds. So the end of the last loop is not when the app is finished running.

Thank you.
Reply
#2
You can use time.perf_counter() to get your start and end times, but timeit() may be a better match for what you want to do. See the docs
Reply
#3
Thanks. I will look into that.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to produce a CPU load for several seconds, and measure it? Calab 2 1,579 Jun-18-2025, 02:19 AM
Last Post: Plyth
  measure diameter of complex structure alminnawi 0 1,297 Apr-18-2024, 10:20 AM
Last Post: alminnawi
  How can I multithread to optimize a groupby task: davisc4468 0 1,610 Jun-30-2023, 02:45 PM
Last Post: davisc4468
  PyCharm Script Execution Time? muzikman 3 11,779 Dec-14-2020, 11:22 PM
Last Post: muzikman
  How to to tie the execution of one process to another inside a loop in Python ignorant_wanderer 0 2,988 Jul-11-2020, 03:44 AM
Last Post: ignorant_wanderer
  Updating a matrix in a time interval inside a for loop vp1989 4 5,014 May-17-2020, 07:15 PM
Last Post: vp1989
  A better way to limit loop execution? t4keheart 3 4,326 Feb-26-2020, 08:24 AM
Last Post: DeaD_EyE
  Loop independent of excecution time of a script Forelli 8 6,653 Feb-02-2020, 10:49 PM
Last Post: snippsat
  Why the multithread does not reduce the execution time? Nicely 2 4,106 Nov-23-2019, 02:28 PM
Last Post: Nicely
  How to Display Multiple Time Tables With While Loop ZQ12 2 3,385 Nov-10-2019, 04:15 AM
Last Post: ZQ12

Forum Jump:

User Panel Messages

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