Skip to content

Commit 79615ff

Browse files
committed
Small optimization on the elapsed time computation
1 parent 5f4e646 commit 79615ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commands/run.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,16 @@ func newJudgeReport() JudgeReport {
196196
}
197197

198198
func timedExecution(cmd *exec.Cmd, timeOut float64) (int8, time.Duration, error) {
199-
start := time.Now()
200199
cmd.Start()
200+
start := time.Now()
201201
done := make(chan error)
202202
go func() { done <- cmd.Wait() }()
203203

204204
timeout := time.After(time.Duration(timeOut) * time.Millisecond)
205205
select {
206206
case <-timeout:
207-
cmd.Process.Kill()
208207
elapsed := time.Since(start)
208+
cmd.Process.Kill()
209209
return TO, elapsed, nil
210210
case err := <-done:
211211
elapsed := time.Since(start)

0 commit comments

Comments
 (0)