Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 164:6b629059c7ab perf_counters
add counter evaluation script (has to be backed up somewhere...)
| author | Nina Engelhardt |
|---|---|
| date | Thu, 15 Sep 2011 18:54:18 +0200 |
| parents | 395f58384a5c |
| children | fe3ff53b55a6 |
| files | Counters/run_graph.py |
| diffstat | 1 files changed, 74 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Counters/run_graph.py Thu Sep 15 18:54:18 2011 +0200 1.3 @@ -0,0 +1,74 @@ 1.4 +#!/usr/bin/python 1.5 + 1.6 +import sys 1.7 +import pygraph 1.8 + 1.9 +if len(sys.argv)<3 : 1.10 + print "Usage:",sys.argv[0],"dependencyfile.dot counterfile.csv" 1.11 + sys.exit() 1.12 + 1.13 +try: 1.14 + dependencyfile = open(sys.argv[1]) 1.15 + dependencystring = dependencyfile.read() 1.16 +except IOError as (errno, strerror): 1.17 + print "Error {0}: {1}".format(errno, strerror) 1.18 + sys.exit() 1.19 + 1.20 +try: 1.21 + counterfile = open(sys.argv[2]) 1.22 +except IOError as (errno, strerror): 1.23 + print "Error {0}: {1}".format(errno, strerror) 1.24 + sys.exit() 1.25 + 1.26 +from pygraph.readwrite.dot import read,write 1.27 + 1.28 +dependencygraph = read(dependencystring) 1.29 + 1.30 +import csv 1.31 + 1.32 +counterreader = csv.reader(counterfile) 1.33 + 1.34 + 1.35 + 1.36 +for row in counterreader: 1.37 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('suspend_point',row[2])) 1.38 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('schedule_check_cycles',int(row[4])-int(row[19]))) 1.39 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('sync_cycles',int(row[25])-int(row[24]))) 1.40 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('assign_cycles',int(row[10])-int(row[7]))) 1.41 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('work_comm_cycles',int(row[16])-int(row[13]))) 1.42 + dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('status_cycles',int(row[22])-int(row[16]))) 1.43 + 1.44 + 1.45 +def path_length(path): 1.46 + length = 0 1.47 + for node in path: 1.48 + attrd = dict(dependencygraph.node_attributes(node)) 1.49 + length += attrd['schedule_check_cycles'] 1.50 + length += attrd['sync_cycles'] 1.51 + length += attrd['assign_cycles'] 1.52 + length += attrd['work_comm_cycles'] 1.53 + length += attrd['status_cycles'] 1.54 + return length 1.55 + 1.56 + 1.57 +def find_critical_path(graph, start, end, path=[]): 1.58 + path = path + [end] 1.59 + if start == end: 1.60 + return path 1.61 + if not graph.has_node(end): 1.62 + return None 1.63 + longest = None 1.64 + for node in graph.incidents(end): 1.65 + if node not in path: 1.66 + newpath = find_critical_path(graph, start, node, path) 1.67 + if newpath: 1.68 + if not longest or path_length(newpath) > path_length(longest): 1.69 + longest = newpath 1.70 + return longest 1.71 + 1.72 +cr= find_critical_path(dependencygraph, 'VP_2_0', 'VP_2_97') 1.73 + 1.74 +for node in cr: 1.75 + dependencygraph.add_node_attribute(node,('color','red')) 1.76 + 1.77 +print write(dependencygraph)
