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
Join the threads, before toc!
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
精彩评论