bin/ci: crnm: Fix job duration calculation
The former version was problematic because: - time.perf_counter() returns seconds relative to an arbitrary point in time (monotonic clock) - time.mktime() converts to epoch time (seconds since 1970) Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Reviewed-by: Sergi Blanch Torne <sergi.blanch.torne@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33750>
This commit is contained in:
committed by
Marge Bot
parent
b3a9125014
commit
ce200e6a4a
@@ -100,7 +100,10 @@ def job_duration(job: gitlab.v4.objects.ProjectPipelineJob) -> float:
|
||||
if job.duration:
|
||||
return job.duration
|
||||
elif job.started_at:
|
||||
return time.perf_counter() - time.mktime(job.started_at.timetuple())
|
||||
# Convert both times to UTC timestamps for consistent comparison
|
||||
current_time = time.time()
|
||||
start_time = job.started_at.timestamp()
|
||||
return current_time - start_time
|
||||
return 0.0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user