Skip to content

Commit 6ec7224

Browse files
committed
Small optimization on the elapsed time computation
1 parent 925c26a commit 6ec7224

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
@@ -200,16 +200,16 @@ func newJudgeReport() JudgeReport {
200200
}
201201

202202
func timedExecution(cmd *exec.Cmd, timeOut float64) (int8, time.Duration, error) {
203-
start := time.Now()
204203
cmd.Start()
204+
start := time.Now()
205205
done := make(chan error)
206206
go func() { done <- cmd.Wait() }()
207207

208208
timeout := time.After(time.Duration(timeOut) * time.Millisecond)
209209
select {
210210
case <-timeout:
211-
cmd.Process.Kill()
212211
elapsed := time.Since(start)
212+
cmd.Process.Kill()
213213
return TO, elapsed, nil
214214
case err := <-done:
215215
elapsed := time.Since(start)

0 commit comments

Comments
 (0)