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()
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
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(algorithm.name + ' ' + status_line + ' ' + speeds + ' warming up, ' + time + '\r', end='') else: print(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(algorithm.name + ': ' + utils.format_speeds(speeds) + ' ' * 22) return speeds
def display_status(self, speeds=defaultdict(lambda: [0.0]), revenue=defaultdict(lambda: 0.0), devices=defaultdict(lambda: [])): algorithms = list(speeds.keys()) algorithms.sort(key=lambda algorithm: algorithm.name) for algorithm in algorithms: data_row = wx.BoxSizer(orient=wx.HORIZONTAL) self._algorithms.Add(data_row, wx.SizerFlags().Expand()) data_row.Add( wx.StaticText( self, label='%s (%s)' % (algorithm.name, ', '.join(algorithm.algorithms))), wx.SizerFlags().Proportion(2.0)) data_row.Add( wx.StaticText(self, label=utils.format_speeds(speeds[algorithm])), wx.SizerFlags().Proportion(1.0)) data_row.Add( wx.StaticText(self, label=utils.format_balance( revenue[algorithm], self._settings['gui']['units'])), wx.SizerFlags().Proportion(1.0)) devices_row = wx.BoxSizer(orient=wx.VERTICAL) self._algorithms.Add(devices_row, wx.SizerFlags().Expand()) for device in devices[algorithm]: text = wx.StaticText(self, label=device.name) if isinstance(device, NvidiaDevice): text.SetBackgroundColour(NVIDIA_COLOR) devices_row.Add( text, wx.SizerFlags().Border(wx.ALL, main.PADDING_PX))
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()