Exemplo n.º 1
0
def run_benchmark(device, algorithm):
    status_dot = [-1]

    def report_speeds(sample, secs_remaining):
        status_dot[0] = (status_dot[0] + 1) % 3
        status_line = ''.join(
            ['.' if i == status_dot[0] else ' ' for i in range(3)])
        if secs_remaining < 0:
            print('  %s %s %s (warming up, %s)\r' %
                  (algorithm.name, status_line, utils.format_speeds(sample),
                   utils.format_time(-secs_remaining)),
                  end='')
        else:
            print('  %s %s %s (sampling, %s)  \r' %
                  (algorithm.name, status_line, utils.format_speeds(sample),
                   utils.format_time(secs_remaining)),
                  end='')
        sys.stdout.flush()

    speeds = utils.run_benchmark(algorithm,
                                 device,
                                 algorithm.warmup_secs,
                                 BENCHMARK_SECS,
                                 sample_callback=report_speeds)

    print('  %s: %s                      ' %
          (algorithm.name, utils.format_speeds(speeds)))
    return speeds
Exemplo n.º 2
0
def run_benchmark(device, algorithm):
    status_dot = [-1]

    def report_speeds(sample, secs_remaining):
        status_dot[0] = (status_dot[0] + 1) % 3
        status_line = ''.join(
            ['.' if i == status_dot[0] else ' ' for i in range(3)])
        speeds = utils.format_speeds(sample)
        time = utils.format_time(abs(secs_remaining))
        if secs_remaining < 0:
            print(
                f'  {algorithm.name} {status_line} {speeds} (warming up, {time})'
                + '\r',
                end='')
        else:
            print(
                f'  {algorithm.name} {status_line} {speeds} (sampling, {time}) '
                + '\r',
                end='')
        sys.stdout.flush()

    speeds = utils.run_benchmark(algorithm,
                                 device,
                                 algorithm.warmup_secs,
                                 BENCHMARK_SECS,
                                 sample_callback=report_speeds)

    print(f'  {algorithm.name}: {utils.format_speeds(speeds)}' + ' ' * 22)
    return speeds
Exemplo n.º 3
0
    def run(self):
        for miner in self._miners:
            miner.load()

        for target in self._targets:

            def report(sample, secs_remaining):
                main.sendMessage(self._window,
                                 'benchmarking.status',
                                 target=target,
                                 speeds=sample,
                                 time=abs(secs_remaining),
                                 warmup=(secs_remaining < 0))

            device, algorithm = target
            speeds = utils.run_benchmark(algorithm,
                                         device,
                                         algorithm.warmup_secs,
                                         BENCHMARK_SECS,
                                         sample_callback=report,
                                         abort_signal=self._abort)
            if self._abort.is_set():
                break
            main.sendMessage(self._window,
                             'benchmarking.set',
                             target=target,
                             speeds=speeds)

        for miner in self._miners:
            miner.unload()

        main.sendMessage(self._window, 'benchmarking.stop')