@@ -55,7 +55,7 @@ def update_group_status(group_status, new_status):
55
55
56
56
57
57
def print_view (term_width , term_height , program_groups_scores , all_results , print_data : PrintData , names , executions ,
58
- groups , scores , tests , possible_score , time_limit , memory_limit , cpus , hide_memory ):
58
+ groups , scores , tests , possible_score , cpus , hide_memory , config ):
59
59
width = term_width - 13 # First column has 6 characters, the " | " separator has 3 characters and 4 for margin
60
60
programs_in_row = width // 13 # Each program has 10 characters and the " | " separator has 3 characters
61
61
@@ -64,9 +64,18 @@ def print_view(term_width, term_height, program_groups_scores, all_results, prin
64
64
sys .stdout = output
65
65
66
66
program_scores = collections .defaultdict (int )
67
- program_times = collections .defaultdict (lambda : - 1 )
68
- program_memory = collections .defaultdict (lambda : - 1 )
69
- time_remaining = (len (executions ) - print_data .i - 1 ) * 2 * time_limit / cpus / 1000.0
67
+ # program_times and program_memory are dictionaries of tuples (max, limit),
68
+ # where max is the maximum time/memory used by a program and
69
+ # limit is the time/memory limit of the test that caused the maximum
70
+ # time/memory usage.
71
+ program_times = collections .defaultdict (lambda : (- 1 , 0 ))
72
+ program_memory = collections .defaultdict (lambda : (- 1 , 0 ))
73
+
74
+ time_sum = 0
75
+ for test in tests :
76
+ time_sum += package_util .get_time_limit (test , config )
77
+
78
+ time_remaining = (len (executions ) - print_data .i - 1 ) * 2 * time_sum / cpus / 1000.0
70
79
title = 'Done %4d/%4d. Time remaining (in the worst case): %5d seconds.' \
71
80
% (print_data .i + 1 , len (executions ), time_remaining )
72
81
title = title .center (term_width )
@@ -104,15 +113,17 @@ def print_table_end():
104
113
min_points = min (min_points , results [test ].Points )
105
114
status = results [test ].Status
106
115
if getattr (results [test ], "Time" ) is not None :
107
- program_times [program ] = max (
108
- program_times [program ], results [test ].Time )
116
+ if program_times [program ][ 0 ] < results [ test ]. Time :
117
+ program_times [program ] = ( results [test ].Time , package_util . get_time_limit ( test , config ) )
109
118
elif status == "TL" :
110
- program_times [program ] = 2 * time_limit
119
+ program_times [program ] = (2 * package_util .get_time_limit (test , config ),
120
+ package_util .get_time_limit (test , config ))
111
121
if getattr (results [test ], "Memory" ) is not None :
112
- program_memory [program ] = max (
113
- program_memory [program ], results [test ].Memory )
122
+ if program_memory [program ][ 0 ] < results [ test ]. Memory :
123
+ program_memory [program ] = ( results [test ].Memory , package_util . get_memory_limit ( test , config ) )
114
124
elif status == "ML" :
115
- program_memory [program ] = 2 * memory_limit
125
+ program_memory [program ] = (2 * package_util .get_memory_limit (test , config ),
126
+ package_util .get_memory_limit (test , config ))
116
127
if status == " " :
117
128
group_status = " "
118
129
min_points = 0
@@ -138,15 +149,15 @@ def print_table_end():
138
149
print (margin + " time" , end = " | " )
139
150
for program in program_group :
140
151
program_time = program_times [program ]
141
- print (util .bold (("%20s" % color_time (program_time , time_limit ))
142
- if program_time < 2 * time_limit and program_time >= 0
152
+ print (util .bold (("%20s" % color_time (program_time [ 0 ], program_time [ 1 ] ))
153
+ if program_time [ 0 ] < 2 * program_time [ 1 ] and program_time [ 0 ] >= 0
143
154
else " " + 7 * '-' ), end = " | " )
144
155
print ()
145
156
print (margin + "memory" , end = " | " )
146
157
for program in program_group :
147
158
program_mem = program_memory [program ]
148
- print (util .bold (("%20s" % color_memory (program_mem , memory_limit ))
149
- if program_mem < 2 * memory_limit and program_mem >= 0
159
+ print (util .bold (("%20s" % color_memory (program_mem [ 0 ], program_mem [ 1 ] ))
160
+ if program_mem [ 0 ] < 2 * program_mem [ 1 ] and program_mem [ 0 ] >= 0
150
161
else " " + 7 * '-' ), end = " | " )
151
162
print ()
152
163
print (8 * " " , end = " | " )
@@ -177,13 +188,15 @@ def print_group_seperator():
177
188
if status == " " : print (10 * ' ' , end = " | " )
178
189
else :
179
190
print ("%3s" % colorize_status (status ),
180
- ("%17s" % color_time (result .Time , time_limit )) if getattr (result , "Time" ) is not None else 7 * " " , end = " | " )
191
+ ("%17s" % color_time (result .Time , package_util .get_time_limit (test , config )))
192
+ if getattr (result , "Time" ) is not None else 7 * " " , end = " | " )
181
193
print ()
182
194
if not hide_memory :
183
195
print (8 * " " , end = " | " )
184
196
for program in program_group :
185
197
result = all_results [program ][package_util .get_group (test )][test ]
186
- print (("%20s" % color_memory (result .Memory , memory_limit )) if getattr (result , "Memory" ) is not None else 10 * " " , end = " | " )
198
+ print (("%20s" % color_memory (result .Memory , package_util .get_memory_limit (test , config )))
199
+ if getattr (result , "Memory" ) is not None else 10 * " " , end = " | " )
187
200
print ()
188
201
189
202
print_table_end ()
@@ -580,7 +593,8 @@ def run_solutions(self, compiled_commands, names, solutions):
580
593
for (name , executable , result ) in compiled_commands :
581
594
if result :
582
595
for test in self .tests :
583
- executions .append ((name , executable , test , self .time_limit , self .memory_limit , self .timetool_path ))
596
+ executions .append ((name , executable , test , package_util .get_time_limit (test , self .config ),
597
+ package_util .get_memory_limit (test , self .config ), self .timetool_path ))
584
598
all_results [name ][self .get_group (test )][test ] = ExecutionResult (" " )
585
599
os .makedirs (os .path .join (self .EXECUTIONS_DIR , name ), exist_ok = True )
586
600
else :
@@ -599,7 +613,7 @@ def run_solutions(self, compiled_commands, names, solutions):
599
613
thr = threading .Thread (target = printer .printer_thread ,
600
614
args = (run_event , print_view , program_groups_scores , all_results , print_data , names ,
601
615
executions , self .groups , self .scores , self .tests , self .possible_score ,
602
- self .time_limit , self .memory_limit , self . cpus , self .args . hide_memory ))
616
+ self .cpus , self .args . hide_memory , self .config ))
603
617
thr .start ()
604
618
605
619
pool = mp .Pool (self .cpus )
@@ -620,7 +634,7 @@ def run_solutions(self, compiled_commands, names, solutions):
620
634
621
635
print ("\n " .join (print_view (terminal_width , terminal_height , program_groups_scores , all_results , print_data ,
622
636
names , executions , self .groups , self .scores , self .tests , self .possible_score ,
623
- self .time_limit , self .memory_limit , self . cpus , self .args . hide_memory )[0 ]))
637
+ self .cpus , self .args . hide_memory , self .config )[0 ]))
624
638
625
639
if keyboard_interrupt :
626
640
util .exit_with_error ("Stopped due to keyboard interrupt." )
0 commit comments