@@ -17,7 +17,6 @@ const compileProblem= async (lang , filename)=>{
1717 case "c++" :
1818 case "cpp" :
1919 file = path . basename ( filename , '.cpp' ) + ".out" ;
20- console . log ( file )
2120 cmd = "cd " + "\"" + path . join ( __dirname , "result/source" ) + "\"" + " && g++ -o \"" + path . join ( __dirname , "result/binary/" ) + "\"" + file + " " + filename ;
2221 break ;
2322 case "java" :
@@ -37,29 +36,32 @@ const compileProblem= async (lang , filename)=>{
3736
3837//Run Compiled if okay the check result
3938
40- async function runCompiled ( lang , file , contest , problem , option ) {
39+ async function runCompiled ( lang , file , contest , problem , option , t0 ) {
4140
4241 var cmd ;
4342 switch ( lang ) {
4443 case "c" :
45- cmd = "cd \"" + path . join ( __dirname , "result/binary" ) + "\" && ./" + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
44+ cmd = "cd " + " \""+ path . join ( __dirname , "result/binary" ) + "\" && ./" + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
4645 break ;
4746 case "c++" :
4847 case "cpp" :
49- cmd = "cd \"" + path . join ( __dirname , "result/binary" ) + "\" && ./" + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
48+ cmd = "cd " + " \""+ path . join ( __dirname , "result/binary" ) + "\" && ./" + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
5049 break ;
5150 case "java" :
52- cmd = "cd \"" + path . join ( __dirname , "result/binary" ) + "\" && java " + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
51+ cmd = "cd " + " \""+ path . join ( __dirname , "result/binary" ) + "\" && java " + file + " <\"" + path . join ( __dirname , "result/input/" ) + contest + "/" + problem + ".txt\"" ;
5352 }
5453
5554 return new Promise ( ( resolve , reject ) => {
5655 exec ( cmd , option , ( error , stdout , stderr ) => {
5756 if ( error ) {
58- //console.log(error)
59- reject ( error ) ;
57+ //console.log(error)
58+ let timelimit = 0 ;
59+ const t1 = process . hrtime ( ) ;
60+ timelimit = ( t1 [ 0 ] - t0 [ 0 ] ) ;
61+ console . log ( timelimit ) ;
62+ reject ( { error, timelimit} ) ;
6063 }
6164 var res = stdout ;
62-
6365 resolve ( res ) ;
6466 } ) ;
6567 } )
@@ -107,10 +109,11 @@ const base64tofile = async (base64,lang)=>{
107109async function compileAndRunProblem ( contest , problem , id , lang , description , option ) {
108110 const filename = await base64tofile ( description , lang ) ;
109111 const file = await compileProblem ( lang , filename ) ;
110- const result = await runCompiled ( lang , file , contest , problem , option ) ;
112+ const t0 = process . hrtime ( ) ;
113+ const result = await runCompiled ( lang , file , contest , problem , option , t0 ) ;
111114 const serverRes = await serverResult ( contest , problem ) ;
112115 const Result = await checkResult ( result , serverRes ) ;
113- console . log ( Result ) ;
116+ // console.log(Result);
114117 return Result ;
115118
116119}
0 commit comments