Esempio n. 1
0
    def on_report_code_coverage(self, event):
        report = GuiReport(self, "Code Coverage Report")

        files = self.instance.model.get_profile()
        instructions = self.instance.model.instructions
        for filename in sorted(profiler.code_files(instructions)):
            lines = files.get(filename, {})
            included = len(profiler.code_lines(filename, instructions))
            executed = len(lines)

            report.report(
                "%s%s%s%s" % (filename.ljust(100), str(included).center(10),
                              str(executed).center(10),
                              100.0 * float(executed) / float(included)),
                float(executed) / float(included))

        total = 0
        for f in sorted(profiler.code_files(instructions)):
            lines = files.get(f, {})
            for lines, count in lines.iteritems():
                total += count

        for filename in sorted(code_files(instructions)):
            lines = files.get(filename, {})
            for line, count in sorted(lines.items(),
                                      key=operator.itemgetter(1),
                                      reverse=True):
                report.report("%s %s %s" %
                              (filename.ljust(100), str(line).center(10)))
                print 100.0 * float(count) / float(total)
Esempio n. 2
0
    def on_report_code_coverage(self, event):
        report = GuiReport(self, "Code Coverage Report")

        files = self.instance.model.get_profile()
        instructions = self.instance.model.instructions
        for filename in sorted(profiler.code_files(instructions)):
            lines    = files.get(filename, {})
            included = len(profiler.code_lines(filename, instructions))
            executed = len(lines)

            report.report("%s%s%s%s"%(
                filename.ljust(100),
                str(included).center(10),
                str(executed).center(10),
                100.0 * float(executed)/float(included)
            ), float(executed)/float(included))

        total = 0
        for f in sorted(profiler.code_files(instructions)):
            lines = files.get(f, {})
            for lines, count in lines.iteritems():
                total += count

        for filename in sorted(code_files(instructions)):
            lines = files.get(filename, {})
            for line, count in sorted(lines.items(), key=operator.itemgetter(1), reverse=True):
                report.report("%s %s %s" %(
                filename.ljust(100),
                str(line).center(10)))
                print 100.0 * float(count) / float(total)
Esempio n. 3
0
    def annotate_coverage(self, filename):
        report = GuiReport(self, "Annotated Code Coverage")

        files = self.instance.model.get_profile()
        instructions = self.instance.model.instructions
        total = 0.0
        for f in sorted(profiler.code_files(instructions)):
            lines = files.get(f, {})
            for lines, count in lines.iteritems():
                total += count

        source = open(filename)
        included = profiler.code_lines(filename, instructions)
        lines = files.get(filename, {})

        for lineno, line in enumerate(source):
            report_line = str(lineno + 1) + " "
            report_line += str(lines.get(lineno + 1, 0)).ljust(10) + " "
            if lineno + 1 in lines:
                report_line += "> "
                status = log(lines[lineno + 1]) / log(total)
            else:
                if lineno + 1 in included:
                    report_line += "! "
                    status = 0
                else:
                    report_line += "- "
                    status = 0

            report.report(report_line + line.strip(), status)
Esempio n. 4
0
    def open_files(self):
        self.file_windows = {}
        self.file_mapping = {}
        code_files = sorted(
            profiler.code_files(self.instance.model.instructions))
        for i, f in enumerate(code_files):
            # use a keyword argument to force argument to be bound now
            def call_handler(event, ff=f):
                return self.on_set_breakpoint(ff, event)

            cw = wx.py.editwindow.EditWindow(self.code, -1)
            cw.Bind(wx.EVT_LEFT_DCLICK, call_handler)
            #cw.Bind(wx.EVT_RIGHT_DOWN, context_menu)
            self.file_windows[f] = cw
            self.code.AddPage(cw, f)
            ff = open(f, "r")
            cw.AddText(ff.read())
            cw.SetReadOnly(True)
            ff.close()
            cw.setDisplayLineNumbers(True)
            self.file_mapping[f] = i

        display = ""
        for i, instruction in enumerate(self.instance.model.instructions):
            z = instruction.get("z", 0)
            a = instruction.get("a", 0)
            b = instruction.get("b", 0)
            o = instruction.get("op", "unknown")
            literal = instruction.get("literal", 0)
            label = instruction.get("label", 0)
            display += "%0.10d: %s %0.2d %0.2d %0.10d\n" % (
                i, o.ljust(11), z, a, (b | label | literal))
        self.instructions_window.AddText(display)
Esempio n. 5
0
    def open_files(self):
        self.file_windows = {}
        self.file_mapping = {}
        code_files = sorted(
            profiler.code_files(self.instance.model.instructions))
        for i, f in enumerate(code_files):
            # use a keyword argument to force argument to be bound now
            def call_handler(event, ff=f):
                return self.on_set_breakpoint(ff, event)
            cw = wx.py.editwindow.EditWindow(self.code, -1)
            cw.Bind(wx.EVT_LEFT_DCLICK, call_handler)
            self.file_windows[f] = cw
            self.code.AddPage(cw, f)
            ff = open(f, "r")
            cw.AddText(ff.read())
            ff.close()
            cw.setDisplayLineNumbers(True)
            self.file_mapping[f] = i

        display = ""
        for i, instruction in enumerate(self.instance.model.instructions):
            z = instruction.get("z", 0)
            a = instruction.get("a", 0)
            b = instruction.get("b", 0)
            o = instruction.get("op", "unknown")
            literal = instruction.get("literal", 0)
            label = instruction.get("label", 0)
            display += "%0.10d: %s %0.2d %0.2d %0.10d\n" % (
                i, o.ljust(11), z, a, (b | label | literal))
        self.instructions_window.AddText(display)
Esempio n. 6
0
    def annotate_coverage(self, filename):
        report = GuiReport(self, "Annotated Code Coverage")
        
        files = self.instance.model.get_profile()
        instructions = self.instance.model.instructions
        total = 0.0
        for f in sorted(profiler.code_files(instructions)):
            lines = files.get(f, {})
            for lines, count in lines.iteritems():
                total += count

        source = open(filename)
        included = profiler.code_lines(filename, instructions)
        lines = files.get(filename, {})

        for lineno, line in enumerate(source):
            report_line = str(lineno+1) + " "
            report_line += str(lines.get(lineno+1, 0)).ljust(10) + " "
            if lineno+1 in lines:
                report_line += "> "
                status = log(lines[lineno + 1])/log(total)
            else:
                if lineno+1 in included:
                    report_line += "! "
                    status = 0
                else:
                    report_line += "- "
                    status = 0

            report.report(report_line + line.strip(), status)