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: ...@@ -10,12 +10,13 @@ except:
ts_factor = 1. ts_factor = 1.
ts_prev = 0. ts_prev = 0.
xxx = [] threadlist = []
for line in data: for line in data:
line = line.rstrip("\n") line = line.rstrip("\n")
vals = line.split() vals = line.split()
[n, tid, ts, funcline] = vals[0:4] [n, tid, ts, funcline] = vals[0:4]
# 'note' is all text following funcline
note = '' note = ''
for v in vals[4:-1]: for v in vals[4:-1]:
note += v+' ' note += v+' '
...@@ -27,32 +28,55 @@ for line in data: ...@@ -27,32 +28,55 @@ for line in data:
time = (float(ts)-ts_prev)/ts_factor time = (float(ts)-ts_prev)/ts_factor
found_it = 0 # create a list of threads
for x in xxx: # - each thread has a list of <note,time> pairs, where time is the accumulated time for that note
if note == x[0]: # - search threadlist for thread_id (tid)
found_it = 1 # - if found, search corresponding list of <note,time> pairs for the current note
x[1] += time # - 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 break
if found_note == 0:
if found_it == 0: thread[1].append([note, time])
xxx.append([note,time]) break
if found_thread == 0:
notetime = []
notetime.append([note, time])
threadlist.append([tid, notetime])
ts_prev = float(ts) ts_prev = float(ts)
# trim out unneeded # trim out unneeded
yyy = [] for thread in threadlist:
for x in xxx: trimlist = []
if x[0][0:9] == 'calibrate': yyy.append(x) for notetime in thread[1]:
if notetime[0][0:9] == 'calibrate':
trimlist.append(notetime)
for notetime in trimlist:
thread[1].remove(notetime)
print ''
for y in yyy: # sum times to calculate percent (of 100)
xxx.remove(y) total_time = 0
for thread in threadlist:
for [note, time] in thread[1]:
total_time += time
print '' 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)
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)
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