Exemple #1
0
  def createEventFrequencyPlot(self, title, events, id = 0):
    # Count the number of each event
    eventFrequency = Collections.DefaultDict(lambda: 0)
    for event in events:
      eventFrequency[event.name] += 1
      
    items = eventFrequency.items()
    items.sort(key = lambda f: -f[1])
      
    funcNames = [f[0] for f in items]
    funcFreq  = [f[1] for f in items]
    
    # Create a bar charts and add a text describing the event to each bar
    pylab.figure()
    pylab.yticks([])
    pylab.ylim(len(funcNames), 0)
    rects = pylab.barh(range(len(funcNames)), funcFreq, color = self.primaryColor)
    
    for name, rect in zip(funcNames, rects):
      pylab.text(rect.get_x() + rect.get_width(), rect.get_y() + rect.get_height(), "  " + name, fontsize = 8)
    
    fn = os.path.join(self.path, title.lower().replace(" ", "_") + "%03d.png" % id)
    pylab.savefig(fn)
    pylab.close()

    section = Report.Section(title)
    section.create(Report.Image, fn)
    return section
Exemple #2
0
 def createEventPlot(self, title, events, sliceStart = 0.0, sliceLength = 10.0, id = 0):
   # See if there's anything to plot
   if not len(events) >= 2:
     return
 
   segmentDuration = (events[-1].time - events[0].time) / 1e6
   
   if segmentDuration < sliceLength:
     sliceLength = events[0].time / 1e6 + segmentDuration
   
   segmentStart    = sliceStart
   slices          = int(segmentDuration / sliceLength) + 2
   
   pylab.figure(figsize = (8, slices * 1))
   pylab.subplot(slices, 1, 1)
   pylab.xlim(sliceStart, sliceStart + sliceLength)
   pylab.yticks([])
   
   legends = {}
   for event in events:
     time     = event.time / 1e6
     duration = event.duration / 1e6
     
     if time + duration > sliceStart + sliceLength:
       pylab.subplot(slices, 1, int((time - segmentStart) / sliceLength) + 1)
       pylab.xticks(size = 7)
       pylab.yticks([])
       sliceStart += sliceLength
       pylab.xlim(sliceStart, sliceStart + sliceLength)
     
     func = self.library.functions[event.name]
     if func.isFrameMarker:
       color = self.highlightColor
       label = "frameswap"
     elif func.isRenderCall:
       color = self.primaryColor
       label = "render"
     else:
       continue
     legends[label] = pylab.axvspan(time, time + max(sliceLength / 100.0, duration), facecolor = color, linewidth = .1, label = label)
 
   # Describe the chart elements
   l1 = []
   l2 = []
   if "render" in legends:
     l1.append(legends["render"])
     l2.append("Render call")
   if "frameswap" in legends:
     l1.append(legends["frameswap"])
     l2.append("Frame swap")
     
   pylab.legend(l1, l2)
   fn = os.path.join(self.path, title.lower().replace(" ", "_") + "%03d.png" % id)
   
   pylab.savefig(fn)
   pylab.close()
 
   section = Report.Section(title)
   section.create(Report.Image, fn)
   return section
Exemple #3
0
    def createEventFrequencyPlot(self, title, events, id=0):
        # Count the number of each event
        eventFrequency = Collections.DefaultDict(lambda: 0)
        for event in events:
            eventFrequency[event.name] += 1

        items = eventFrequency.items()
        items.sort(key=lambda f: -f[1])

        funcNames = [f[0] for f in items]
        funcFreq = [f[1] for f in items]

        # Create a bar charts and add a text describing the event to each bar
        pylab.figure()
        pylab.yticks([])
        pylab.ylim(len(funcNames), 0)
        rects = pylab.barh(range(len(funcNames)),
                           funcFreq,
                           color=self.primaryColor)

        for name, rect in zip(funcNames, rects):
            pylab.text(rect.get_x() + rect.get_width(),
                       rect.get_y() + rect.get_height(),
                       "  " + name,
                       fontsize=8)

        fn = os.path.join(self.path,
                          title.lower().replace(" ", "_") + "%03d.png" % id)
        pylab.savefig(fn)
        pylab.close()

        section = Report.Section(title)
        section.create(Report.Image, fn)
        return section
Exemple #4
0
  def createPlot(self, title, xAxis, yAxis, id = 0, style = "line"):
    # See if there's anything to plot
    for value in yAxis:
      if value:
        break
    else:
      return
    
    pylab.clf()
    Charting.slicePlot(xAxis, yAxis, color = self.primaryColor, style = style)
    fn = os.path.join(self.path, title.lower().replace(" ", "_") + "%03d.png" % id)
    pylab.savefig(fn)
    pylab.close()

    section = Report.Section(title)
    section.create(Report.Image, fn)
    return section
Exemple #5
0
    def createPlot(self, title, xAxis, yAxis, id=0, style="line"):
        # See if there's anything to plot
        for value in yAxis:
            if value:
                break
        else:
            return

        pylab.clf()
        Charting.slicePlot(xAxis, yAxis, color=self.primaryColor, style=style)
        fn = os.path.join(self.path,
                          title.lower().replace(" ", "_") + "%03d.png" % id)
        pylab.savefig(fn)
        pylab.close()

        section = Report.Section(title)
        section.create(Report.Image, fn)
        return section
Exemple #6
0
    def createEventPlot(self,
                        title,
                        events,
                        sliceStart=0.0,
                        sliceLength=10.0,
                        id=0):
        # See if there's anything to plot
        if not len(events) >= 2:
            return

        segmentDuration = (events[-1].time - events[0].time) / 1e6

        if segmentDuration < sliceLength:
            sliceLength = events[0].time / 1e6 + segmentDuration

        segmentStart = sliceStart
        slices = int(segmentDuration / sliceLength) + 2

        pylab.figure(figsize=(8, slices * 1))
        pylab.subplot(slices, 1, 1)
        pylab.xlim(sliceStart, sliceStart + sliceLength)
        pylab.yticks([])

        legends = {}
        for event in events:
            time = event.time / 1e6
            duration = event.duration / 1e6

            if time + duration > sliceStart + sliceLength:
                pylab.subplot(slices, 1,
                              int((time - segmentStart) / sliceLength) + 1)
                pylab.xticks(size=7)
                pylab.yticks([])
                sliceStart += sliceLength
                pylab.xlim(sliceStart, sliceStart + sliceLength)

            func = self.library.functions[event.name]
            if func.isFrameMarker:
                color = self.highlightColor
                label = "frameswap"
            elif func.isRenderCall:
                color = self.primaryColor
                label = "render"
            else:
                continue
            legends[label] = pylab.axvspan(time,
                                           time +
                                           max(sliceLength / 100.0, duration),
                                           facecolor=color,
                                           linewidth=.1,
                                           label=label)

        # Describe the chart elements
        l1 = []
        l2 = []
        if "render" in legends:
            l1.append(legends["render"])
            l2.append("Render call")
        if "frameswap" in legends:
            l1.append(legends["frameswap"])
            l2.append("Frame swap")

        pylab.legend(l1, l2)
        fn = os.path.join(self.path,
                          title.lower().replace(" ", "_") + "%03d.png" % id)

        pylab.savefig(fn)
        pylab.close()

        section = Report.Section(title)
        section.create(Report.Image, fn)
        return section