def bench(self, loops, multiply, func, msg): print("\n%s benchmark" % msg) self.setUp() self.cpu.cycles = 0 txt = string.printable if not PY2: txt = bytes(txt, encoding="UTF-8") txt = txt * multiply print("\nStart %i %s loops with %i Bytes test string..." % (loops, msg, len(txt))) start_time = time.time() for __ in range(loops): self._crc32(txt) duration = time.time() - start_time print("%s benchmark runs %s CPU cycles in %.2f sec" % (msg, locale_format_number(self.cpu.cycles), duration)) return duration, self.cpu.cycles
def bench(self, loops, multiply, func, msg): print("\n%s benchmark" % msg) self.setUp() self.cpu.cycles = 0 txt = string.printable if not PY2: txt = bytes(txt, encoding="UTF-8") txt = txt * multiply print("\nStart %i %s loops with %i Bytes test string..." % ( loops, msg, len(txt) )) start_time = time.time() for __ in range(loops): self._crc32(txt) duration = time.time() - start_time print("%s benchmark runs %s CPU cycles in %.2f sec" % ( msg, locale_format_number(self.cpu.cycles), duration )) return duration, self.cpu.cycles
def run_benchmark(loops, multiply): total_duration = 0 total_cycles = 0 bench_class = Test6809_Program2() #-------------------------------------------------------------------------- duration, cycles = bench_class.crc16_benchmark(loops, multiply) total_duration += duration total_cycles += cycles #-------------------------------------------------------------------------- duration, cycles = bench_class.crc32_benchmark(loops, multiply) total_duration += duration total_cycles += cycles #-------------------------------------------------------------------------- print("-" * 79) print("\nTotal of %i benchmak loops run in %.2f sec %s CPU cycles." % (loops, total_duration, locale_format_number(total_cycles))) print("\tavg.: %s CPU cycles/sec" % locale_format_number(total_cycles / total_duration))
def run_benchmark(loops, multiply): total_duration = 0 total_cycles = 0 bench_class = Test6809_Program2() #-------------------------------------------------------------------------- duration, cycles = bench_class.crc16_benchmark(loops, multiply) total_duration += duration total_cycles += cycles #-------------------------------------------------------------------------- duration, cycles = bench_class.crc32_benchmark(loops, multiply) total_duration += duration total_cycles += cycles #-------------------------------------------------------------------------- print("-"*79) print("\nTotal of %i benchmak loops run in %.2f sec %s CPU cycles." % ( loops, total_duration, locale_format_number(total_cycles) )) print("\tavg.: %s CPU cycles/sec" % locale_format_number(total_cycles / total_duration))