Description:
add run_stat checking
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r160:f0502be39e3b - - 3 files changed: 48 inserted, 10 deleted
@@ -66,6 +66,7 | |||
|
66 | 66 | |
|
67 | 67 | result_fname = "#{test_result_dir}/result" |
|
68 | 68 |
comment_fname = "#{test_result_dir}/comment" |
|
69 | + runstat_fname = "#{test_result_dir}/run_stat" | |
|
69 | 70 | if FileTest.exist?(result_fname) |
|
70 | 71 | comment = "" |
|
71 | 72 | begin |
@@ -85,9 +86,22 | |||
|
85 | 86 | comment += "" |
|
86 | 87 | end |
|
87 | 88 | |
|
88 | - return {:points => result, | |
|
89 | - :comment => comment, | |
|
90 | - :cmp_msg => cmp_msg} | |
|
89 | + begin | |
|
90 | + runstat_file = File.open(runstat_fname) | |
|
91 | + max_runtime = runstat_file.readline.to_f | |
|
92 | + peak_memory = runstat_file.readline.to_i | |
|
93 | + rescue | |
|
94 | + max_runtime = -1 | |
|
95 | + peak_memory = -1 | |
|
96 | + end | |
|
97 | + | |
|
98 | + | |
|
99 | + return {points: result, | |
|
100 | + comment: comment, | |
|
101 | + cmp_msg: cmp_msg, | |
|
102 | + max_runtime: max_runtime, | |
|
103 | + peak_memory: peak_memory | |
|
104 | + } | |
|
91 | 105 | else |
|
92 | 106 | if FileTest.exist?("#{test_result_dir}/a.out") |
|
93 | 107 | return {:points => 0, |
@@ -108,6 +122,10 | |||
|
108 | 122 | submission.points = points |
|
109 | 123 | comment = @config.report_comment(result[:comment]) |
|
110 | 124 | |
|
125 | + submission.peak_memory = result[:peak_memory] | |
|
126 | + submission.max_runtime = result[:max_runtime] | |
|
127 | + submission.effective_code_length =submission.source.length | |
|
128 | + | |
|
111 | 129 | # |
|
112 | 130 | # TODO: FIX THIS MESSAGE |
|
113 | 131 | # |
@@ -1456,11 +1456,6 | |||
|
1456 | 1456 | err("TO: Time limit exceeded (wall clock)"); |
|
1457 | 1457 | flush_line(); |
|
1458 | 1458 | fprintf(stderr,"OK\n"); |
|
1459 | - print_running_stat( | |
|
1460 | - (double)wall_ms/1000, | |
|
1461 | - (double)total_ms/1000, | |
|
1462 | - (double)sys_ms/1000, | |
|
1463 | - (mem_peak_kb + 1023) / 1024); | |
|
1464 | 1459 | box_exit(0); |
|
1465 | 1460 | } |
|
1466 | 1461 | if (WIFSIGNALED(stat)) |
@@ -31,6 +31,17 | |||
|
31 | 31 | end |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | + def extract_time(t) | |
|
35 | + puts "TIME: #{t}" | |
|
36 | + if (result=/^(.*)r(.*)u(.*)s(.*)m/.match(t)) | |
|
37 | + {:real => result[1], :user => result[2], :sys => result[3], :mem => result[4]} | |
|
38 | + else | |
|
39 | + #{:real => 0, :user => 0, :sys => 0} | |
|
40 | + #puts "ERROR READING RUNNING TIME: #{t}" | |
|
41 | + raise "Error reading running time: #{t}" | |
|
42 | + end | |
|
43 | + end | |
|
44 | + | |
|
34 | 45 | problem_home = ENV['PROBLEM_HOME'] |
|
35 | 46 | require "#{problem_home}/script/test_dsl.rb" |
|
36 | 47 | load "#{problem_home}/test_cases/all_tests.cfg" |
@@ -43,6 +54,8 | |||
|
43 | 54 | |
|
44 | 55 | all_score = 0 |
|
45 | 56 | all_comment = '' |
|
57 | + peak_memory = -1 | |
|
58 | + max_runtime = -1 | |
|
46 | 59 | (1..(problem.runs.length-1)).each do |k| |
|
47 | 60 | log "grade run #{k}" |
|
48 | 61 | run = problem.runs[k] |
@@ -58,10 +71,15 | |||
|
58 | 71 | else |
|
59 | 72 | result_file = File.new(result_file_name, "r") |
|
60 | 73 | result_file_lines = result_file.readlines |
|
61 |
- if result_file_lines.length>= |
|
|
74 | + if result_file_lines.length>=3 | |
|
62 | 75 | current_run_score = result_file_lines[1].to_i |
|
63 | 76 | run_comment += result_file_lines[0] |
|
64 | 77 | run_comment_short += char_comment(result_file_lines[0].chomp) |
|
78 | + | |
|
79 | + #update max runtime & memory | |
|
80 | + run_stat = extract_time result_file_lines[2] | |
|
81 | + peak_memory = [peak_memory,run_stat[:mem].to_i].max | |
|
82 | + max_runtime = [max_runtime,run_stat[:user].to_f + run_stat[:sys].to_f].max | |
|
65 | 83 | else |
|
66 | 84 | current_run_score = 0 |
|
67 | 85 | run_comment += "result file for test #{test_num} error\n" |
@@ -105,4 +123,11 | |||
|
105 | 123 | comment_file.write "#{all_comment}\n" |
|
106 | 124 | comment_file.close |
|
107 | 125 | |
|
108 | - log "score = #{all_score} comment = #{all_comment}" | |
|
126 | + | |
|
127 | + File.open("run_stat","w") do |file| | |
|
128 | + file.puts max_runtime | |
|
129 | + file.puts peak_memory | |
|
130 | + end | |
|
131 | + | |
|
132 | + log "score = #{all_score}\ncomment = #{all_comment}" | |
|
133 | + log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}" |
You need to be logged in to leave comments.
Login now