Commit 40a9184e authored by Dave Wells's avatar Dave Wells Committed by Yoni Fogel

add thread parsing

git-svn-id: file:///svn/toku/tokudb@19929 c7de825b-a66e-492c-adef-691d508d4ae1
parent ee819135
......@@ -10,12 +10,13 @@ except:
ts_factor = 1.
ts_prev = 0.
xxx = []
threadlist = []
for line in data:
line = line.rstrip("\n")
vals = line.split()
[n, tid, ts, funcline] = vals[0:4]
# 'note' is all text following funcline
note = ''
for v in vals[4:-1]:
note += v+' '
......@@ -27,32 +28,55 @@ for line in data:
time = (float(ts)-ts_prev)/ts_factor
found_it = 0
for x in xxx:
if note == x[0]:
found_it = 1
x[1] += time
# create a list of threads
# - each thread has a list of <note,time> pairs, where time is the accumulated time for that note
# - search threadlist for thread_id (tid)
# - if found, search corresponding list of <note,time> pairs for the current note
# - if found, update (+=) the time
# - if not found, create a new <note,time> pair
# - if not found, create a new thread,<note,time> entry
found_thread = 0
for thread in threadlist:
if tid == thread[0]:
found_thread = 1
notetimelist = thread[1]
found_note = 0
for notetime in notetimelist:
if note == notetime[0]:
found_note = 1
notetime[1] += time
break
if found_note == 0:
thread[1].append([note, time])
break
if found_it == 0:
xxx.append([note,time])
if found_thread == 0:
notetime = []
notetime.append([note, time])
threadlist.append([tid, notetime])
ts_prev = float(ts)
# trim out unneeded
yyy = []
for x in xxx:
if x[0][0:9] == 'calibrate': yyy.append(x)
for y in yyy:
xxx.remove(y)
print ''
total_time = 0;
for x in xxx:
total_time += x[1]
for x in xxx:
print "%20s %5d" % (x[0], 100.*x[1]/total_time)
for thread in threadlist:
trimlist = []
for notetime in thread[1]:
if notetime[0][0:9] == 'calibrate':
trimlist.append(notetime)
for notetime in trimlist:
thread[1].remove(notetime)
print ''
# sum times to calculate percent (of 100)
total_time = 0
for thread in threadlist:
for [note, time] in thread[1]:
total_time += time
print ' thread operation time(sec) percent'
for thread in threadlist:
print 'tid : %5s' % thread[0]
for [note, time] in thread[1]:
print ' %20s %f %5d' % (note, time, 100. * time/total_time)
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