예제 #1
0
 def flush(self):
     cpunames = sorted(self.cpunames)
     if not self.printed_header:
         ts = ["Timestamp"] if self.timestamp else []
         self.writer.writerow(ts + ["Area", "Node"] + cpunames + ["Description", "Sample", "Stddev", "Multiplex"])
         self.printed_header = True
     for key in sorted(sorted(self.nodes.keys(), key=lambda x: x[1]), key=lambda x: x[0] == ""):
         node = self.nodes[key]
         ts = [convert_ts(self.timestamp)] if self.timestamp else []
         l = ts + [key[0], key[1]]
         vlist = []
         ol = dict()
         desc, sample = "", ""
         for cpuname in cpunames:
             if cpuname in node:
                 cpu = node[cpuname]
                 if cpu[2]:
                     desc = cpu[2]
                     desc = re.sub(r"\s+", " ", desc)
                 if cpu[3]:
                     sample = cpu[3]
                 # ignore remark for now
                 if cpu[4]:
                     vlist.append(cpu[4])
                 ol[cpuname] = float(cpu[0])
         l += [ol[x] if x in ol else "" for x in cpunames]
         l.append(desc)
         l.append(sample)
         vs = combine_valstat(vlist)
         if vs:
             l += (vs.stddev, vs.multiplex if not isnan(vs.multiplex) else "")
         else:
             l += ["", ""]
         self.writer.writerow(l)
     self.nodes = dict()
예제 #2
0
 def flush(self):
     cpunames = sorted(self.cpunames)
     if not self.printed_header:
         ts = ["Timestamp"] if self.timestamp else []
         self.writer.writerow(ts + ["Area", "Node"] + cpunames + ["Description", "Sample", "Stddev", "Multiplex"])
         self.printed_header = True
     for key in sorted(sorted(self.nodes.keys(), key=lambda x: x[1]), key=lambda x: x[0] == ""):
         node = self.nodes[key]
         ts = [self.timestamp] if self.timestamp else []
         l = ts + [key[0], key[1]]
         vlist = []
         ol = dict()
         desc, sample = "", ""
         for cpuname in cpunames:
             if cpuname in node:
                 cpu = node[cpuname]
                 if cpu[2]:
                     desc = cpu[2]
                 if cpu[3]:
                     sample = cpu[3]
                 # ignore remark for now
                 if cpu[4]:
                     vlist.append(cpu[4])
                 ol[cpuname] = float(cpu[0])
         l += [ol[x] if x in ol else "" for x in cpunames]
         l.append(desc)
         l.append(sample)
         vs = combine_valstat(vlist)
         if vs:
             l += (vs.stddev, vs.multiplex if not isnan(vs.multiplex) else "")
         else:
             l += ["", ""]
         self.writer.writerow(l)
     self.nodes = dict()
예제 #3
0
 def show(self, timestamp, title, area, hdr, val, remark, desc, sample, bn):
     if self.args.no_desc:
         desc = ""
     desc = re.sub(r"\s+", " ", desc)
     l = []
     if timestamp:
         l.append(convert_ts(timestamp))
     if title:
         l.append(title)
     stddev = val.format_uncertainty().strip()
     multiplex = val.multiplex if not isnan(val.multiplex) else ""
     self.writer.writerow(l + [
         hdr,
         val.format_value_raw().strip(), remark, desc, sample, stddev,
         multiplex, bn
     ])
예제 #4
0
    def flush(self):
        nodes = OrderedDict()
        for hdr in self.headers:
            for title in sorted(self.nodes.keys()):
                if hdr not in self.nodes[title]:
                    continue
                nd = self.nodes[title]
                val = nd[hdr].value if isinstance(nd[hdr], UVal) else nd[hdr]

                if title:
                    title += " "
                if hdr in ("Frontend_Bound", "Backend_Bound", "BadSpeculation",
                           "Retiring"):  # XXX
                    key = title + "Level1"
                    if key not in nodes:
                        nodes[key] = dict()
                    nodes[title + "Level1"][hdr] = val
                elif hdr.count(".") >= 1:
                    dot = hdr.rindex(".")
                    nodes[title + hdr[:dot]] = {hdr: round(val, 2)}
                else:  # assume it's metric
                    nodes[title + hdr] = {hdr: val}

        for name in nodes.keys():
            if self.count[self.curname] == 0:
                if not self.no_header:
                    self.logf.write("[\n")
            else:
                self.logf.write(",\n")
            json.dump(
                {
                    "name":
                    name,
                    "ph":
                    "C",
                    "pid":
                    0,
                    "ts":
                    self.timestamp /
                    1e6 if self.timestamp and not isnan(self.timestamp) else 0,
                    "args":
                    nodes[name]
                }, self.logf)
            self.count[self.curname] += 1
        self.nodes = defaultdict(dict)
        self.headers = OrderedDict()
예제 #5
0
 def show(self, timestamp, title, area, hdr, val, unit, desc, sample, bn,
          below, idle):
     self.print_header(timestamp, title)
     if self.args.no_desc:
         desc = ""
     desc = re.sub(r"\s+", " ", desc)
     l = []
     if timestamp:
         l.append(convert_ts(timestamp))
     if title:
         l.append("CPU" + title if re.match(r'[0-9]+', title) else title)
     stddev = val.format_uncertainty().strip()
     multiplex = val.multiplex if not isnan(val.multiplex) else ""
     self.writer[self.curname].writerow(l + [
         hdr,
         val.format_value_raw().strip(), (unit + " " + fmt_below(below)).
         strip(), desc, sample, stddev, multiplex, bn, "Y" if idle else ""
     ])
예제 #6
0
 def print_timestamp(self, timestamp):
     if timestamp:
         if isnan(timestamp):
             self.logf.write("%-11s " % "SUMMARY")
         else:
             self.logf.write("%6.9f " % timestamp)
예제 #7
0
def convert_ts(ts):
    if isnan(ts):
        return "SUMMARY"
    return ts