예제 #1
0
    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
예제 #2
0
파일: bechmark.py 프로젝트: 6809/MC6809
    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
예제 #3
0
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))
예제 #4
0
파일: bechmark.py 프로젝트: 6809/MC6809
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))