I am running the following code try to measure how long my PG process finish, however, the "toc-tic" displays as soon as the whole loop finish, is there any way that I can measure the total time and time for individual thread? Thanks
tic = time.clock()
for i in range(0,2):
start = i * step
end = start + step
pg = PatternGenerator()
pg.counter = start
pg.pos = i
pg.data = lines[start:end]
pg.start()
toc = time.clock()
print toc - tic
Regards, Andy
You can put the objects to a list, then call join on them!
before the for:
pglist = []
... start the threads...
for pg in pglist:
pg.join()
toc = time.clock()
print toc - tic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.