示例#1
0
    def finish(self):
        GraphCombiner.finish(self)
        cluster_index = 0
        clusters = {}
        for domain, data in self.per_domain.items():
            cluster = clusters.setdefault(cluster_index, [])
            cluster.append('subgraph cluster_%d {\nlabel = "%s";' %
                           (cluster_index, domain))
            # counters
            for counter_name, counter_data in data['counters'].items():
                id = self.make_id(domain, counter_name)
                self._write(
                    '%s [label="{COUNTER: %s|min=%s|max=%s|avg=%s}"];\n' %
                    (id, html.escape(counter_name),
                     format_time(
                         min(counter_data)), format_time(max(counter_data)),
                     format_time(sum(counter_data) / len(counter_data))))
                cluster.append("%s;" % (id))
            # tasks
            for task_name, task_data in data['tasks'].items():
                id = self.make_id(domain, task_name)
                time = task_data['time']
                self._write(
                    '%s [label="{TASK: %s|min=%s|max=%s|avg=%s|count=%d%s}"];\n'
                    % (id, html.escape(task_name), format_time(
                        min(time)), format_time(max(time)),
                       format_time(sum(time) / len(time)), len(time),
                       (("|%s" % task_data['src'].replace('\\', '/'))
                        if 'src' in task_data else "")))
                cluster.append("%s;" % id)
            #: {}, 'objects':{}, 'frames': {}, 'markers': {}
            cluster_index += 1
        # threads
        thread_names = self.tree['threads']
        for tid in self.threads:
            tid_str, tid_hex = str(tid), (to_hex(tid)
                                          if tid is not None else "None")
            id = self.make_id("threads", tid_str)
            thread_name = thread_names[
                tid_str] if tid_str in thread_names else ""
            self._write(
                '%s [label="{THREAD: %s|%s}" color=gray fontcolor=gray];\n' %
                (id, tid_hex, html.escape(thread_name)))

        # clusters
        for _, cluster in clusters.items():
            for line in cluster:
                self._write(line + "\n")
            self._write("}\n")
        # relations
        for relation in self.relations.values():
            if 'color' not in relation:
                relation['color'] = 'black'
            self._write(
                'edge [label="{label}" color={color} fontcolor={color}];\n{from}->{to};\n'
                .format(**relation))

        self._write("}\n")
        self.file.close()
示例#2
0
 def finish(self):
     GraphCombiner.finish(self)
     for (domain, data) in iteritems(self.per_domain):
         for (task_name, task_data) in iteritems(data['tasks']):
             time = task_data['time']
             self.file.write(
                 '%s,%s,%s,%s,%s,%d\n' %
                 (cgi.escape(domain), cgi.escape(task_name), min(time),
                  max(time), sum(time) / len(time), len(time)))
     self.file.close()
示例#3
0
 def finish(self):
     GraphCombiner.finish(self)
     delim = ','
     with open(self.get_targets()[-1], 'w') as f:
         writer = csv.writer(f, delimiter=delim)
         writer.writerow(
             ["domain", "name", "min", "max", "avg", "total", "count"])
         for domain, data in self.per_domain.items():
             for task_name, task_data in data['tasks'].items():
                 time = task_data['time']
                 writer.writerow([
                     domain, task_name,
                     min(time),
                     max(time),
                     sum(time) / len(time),
                     sum(time),
                     len(time)
                 ])
示例#4
0
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)
     self.file = open(self.get_targets()[-1], "w+b")
     self.file.write(
         """<?xml version='1.0' encoding='utf-8'?>\n<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">"""
     )
示例#5
0
    def finish(self):
        GraphCombiner.finish(self)
        self.file.write('<Nodes>\n')
        for domain, data in self.per_domain.iteritems():
            # counters
            for counter_name, counter_data in data['counters'].iteritems():
                id = self.make_id(domain, counter_name)
                self.file.write(
                    '<Node Id="%s" Label="%s" Min="%g" Max="%g" Avg="%g" Category="CodeSchema_Type"/>\n'
                    %
                    (id, cgi.escape(counter_name), min(counter_data),
                     max(counter_data), sum(counter_data) / len(counter_data)))
            # tasks
            for task_name, task_data in data['tasks'].iteritems():
                id = self.make_id(domain, task_name)
                time = task_data['time']
                self.file.write(
                    '<Node Id="%s" Category="CodeSchema_Method" Label="%s" Min="%s" Max="%s" Avg="%s" Count="%d" Src="%s"/>\n'
                    % (id, cgi.escape(task_name), format_time(
                        min(time)), format_time(
                            max(time)), format_time(sum(time) / len(time)),
                       len(time), task_data['src'].replace('\\', '/')
                       if task_data.has_key('src') else ""))
            self.file.write(
                '<Node Id="%s" Label="%s" Category="CodeSchema_Namespace" Group="Expanded"/>\n'
                % (self.make_id("domain", domain), cgi.escape(domain)))
        # threads
        thread_names = self.tree['threads']
        for tid in self.threads:
            tid_str, tid_hex = str(tid), (to_hex(tid)
                                          if tid is not None else "None")
            id = self.make_id("threads", tid_str)
            thread_name = thread_names[tid_str] if thread_names.has_key(
                tid_str) else ""
            self.file.write('<Node Id="%s" Label="%s(%s)"/>\n' %
                            (id, cgi.escape(thread_name), tid_hex))

        self.file.write('</Nodes>\n')
        self.file.write('<Links>\n')

        # relations
        for relation in self.relations.itervalues():
            if not relation.has_key('color'):
                relation['color'] = 'black'
            self.file.write(
                '<Link Source="{from}" Target="{to}" Category="CodeSchema_Calls"/>\n'
                .format(**relation))

        for domain, data in self.per_domain.iteritems():
            # counters
            for counter_name, counter_data in data['counters'].iteritems():
                self.file.write(
                    '<Link Source="%s" Target="%s" Category="Contains"/>\n' %
                    (self.make_id("domain",
                                  domain), self.make_id(domain, counter_name)))
            # tasks
            for task_name, task_data in data['tasks'].iteritems():
                self.file.write(
                    '<Link Source="%s" Target="%s" Category="Contains"/>\n' %
                    (self.make_id("domain",
                                  domain), self.make_id(domain, task_name)))

        self.file.write('</Links>\n')

        self.file.write("</DirectedGraph>\n")
        self.file.close()
示例#6
0
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)
     self.file = open(self.get_targets()[-1], "w+b")
     self.file.write(
         "digraph G{\nedge [labeldistance=0];\nnode [shape=record];\n")
示例#7
0
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)
     self.file = open(self.get_targets()[-1], "w+b")
     self.file.write("digraph G{\nedge [labeldistance=0];\nnode [shape=record];\n")
示例#8
0
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)
     self.file = open(self.get_targets()[-1], "w+b")
     self.file.write("domain,name,min,max,avg,count\n")
示例#9
0
文件: DGML.py 项目: ChoiJK/IntelSEAPI
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)
     self.file = open(self.get_targets()[-1], "w+b")
     self.file.write("""<?xml version='1.0' encoding='utf-8'?>\n<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">""")
示例#10
0
 def __init__(self, args, tree):
     GraphCombiner.__init__(self, args, tree)