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)
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)
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)
def report_memory_usage(self, event): report = GuiReport(self, "memory usage report") report.report("memory usage report for %s\n" % self.chip.name, 0) report.report("data memory:", 0) for instance in self.chip.instances: report_line = "%20s : %4u KiB + %4u bytes (%4u 32 bit words)" % ( instance.component_name, (instance.model.max_stack * 4) // 1024, (instance.model.max_stack * 4) % 1024, instance.model.max_stack, ) report.report(report_line, 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)
def report_memory_usage(self, event): report = GuiReport(self, "memory usage report") report.report("memory usage report for %s\n"%self.chip.name, 0) report.report("data memory:", 0) for instance in self.chip.instances: report_line = "%20s : %4u KiB + %4u bytes (%4u 32 bit words)"%( instance.component_name, (instance.model.max_stack*4) // 1024, (instance.model.max_stack*4) % 1024, instance.model.max_stack, ) report.report(report_line, 0)