My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add timing delta to benchmark output

+7 -6
+7 -6
advent.py
··· 34 34 35 35 36 36 def color_time_str(str, timespan): 37 - if timespan >= 10: 37 + if abs(timespan) >= 10: 38 38 color = bcolors.FAIL 39 - elif timespan >= 1: 39 + elif abs(timespan) >= 1: 40 40 color = bcolors.WARNING 41 41 else: 42 42 color = '' ··· 110 110 to_run.append((program, day, input_file, output_file)) 111 111 112 112 if args.benchmark: 113 - print "Day CPython PyPy Speedup" 114 - print '-' * 34 113 + print "Day CPython PyPy Delta Speedup" 114 + print '-' * 45 115 115 116 116 for program, day, input_file, output_file in to_run: 117 117 cpy_time = check_solution(program, day, input_file, output_file, pypy=False)[2] 118 118 pypy_time = check_solution(program, day, input_file, output_file, pypy=True)[2] 119 119 120 - print "{:02} {} {} {:0.1f}".format( 120 + print "{:02} {} {} {} {:0.1f}".format( 121 121 day, 122 122 format_time(cpy_time, padding=7), 123 123 format_time(pypy_time, padding=7), 124 - cpy_time / pypy_time 124 + format_time(cpy_time - pypy_time, padding=9), 125 + cpy_time / pypy_time, 125 126 ) 126 127 127 128 sys.exit(0)