def write_time( cpu_times, emphasise=False ): def write( text ): if not emphasise: sys.stdout.write( text ) else: sys.stdout.write( as_emphasised( text ) ) write( " Time:" ) write( " Wall [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.wall ) ) ) ) write( " ] CPU [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.process ) ) ) ) write( " ] CPU/Wall [ {}".format( as_colour( 'time', as_wall_cpu_percent_string( cpu_times ) ) ) ) write( " ]" )
def write_time(cpu_times, emphasise=False): def write(text): if not emphasise: sys.stdout.write(text) else: sys.stdout.write(as_emphasised(text)) write(" Time:") write(" Wall [ {}".format( emphasise_time_by_digit(as_duration_string(cpu_times.wall)))) write(" ] CPU [ {}".format( emphasise_time_by_digit(as_duration_string(cpu_times.process)))) write(" ] CPU/Wall [ {}".format( as_colour('time', as_wall_cpu_percent_string(cpu_times)))) write(" ]")
def _time_string(cls, nanoseconds): time_text = cuppa.timer.as_duration_string(nanoseconds) return emphasise_time_by_digit( time_text, start_colour=" ", start_highlight='<span class="font-weight-bold">', end_highlight='</span>')
def _time_string( cls, nanoseconds ): time_text = cuppa.timer.as_duration_string( nanoseconds ) return emphasise_time_by_digit( time_text, start_colour=" ", start_highlight='<span class="font-weight-bold">', end_highlight='</span>' )
def __write_time(self, results): sys.stdout.write(" Time:") if 'wall_duration' in results: sys.stdout.write(" Wall [ %s ]" % emphasise_time_by_digit(results['wall_duration'])) sys.stdout.write(" CPU [ %s ]" % emphasise_time_by_digit(results['cpu_duration'])) if 'wall_cpu_percent' in results: wall_cpu_percent = results['wall_cpu_percent'].upper() format = "%6s%%" if wall_cpu_percent == "N/A": format = "%5s " wall_cpu_percent = format % wall_cpu_percent sys.stdout.write(" CPU/Wall [ %s ]" % as_colour('time', wall_cpu_percent))
def __write_time( self, results ): sys.stdout.write( " Time:" ) if 'wall_duration' in results: sys.stdout.write( " Wall [ %s ]" % emphasise_time_by_digit( results['wall_duration'] ) ) sys.stdout.write( " CPU [ %s ]" % emphasise_time_by_digit( results['cpu_duration'] ) ) if 'wall_cpu_percent' in results: wall_cpu_percent = results['wall_cpu_percent'].upper() format = "%6s%%" if wall_cpu_percent == "N/A": format = "%5s " wall_cpu_percent = format % wall_cpu_percent sys.stdout.write( " CPU/Wall [ %s ]" % as_colour( 'time', wall_cpu_percent ) )
def as_string( cpu_times ): return "Time: Wall [ {} ] CPU [ {} ] CPU/Wall [ {} ]".format( emphasise_time_by_digit( as_duration_string( cpu_times.wall ) ), emphasise_time_by_digit( as_duration_string( cpu_times.process ) ), as_colour( 'time', as_wall_cpu_percent_string( cpu_times ) ) )