Record independent campaign clocks and matched Newton follow-up cases

This commit is contained in:
2026-09-18 11:40:36 -04:00
parent 25816d4328
commit 18762298c1
3 changed files with 217 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import math
import os
from pathlib import Path
import platform
import resource
import shutil
import subprocess
import time
@@ -133,6 +134,7 @@ def main():
state_files[str(path)] = digest(path)
print('START', name, flush=True)
start = time.monotonic()
cpu_start = resource.getrusage(resource.RUSAGE_CHILDREN)
record = {'id': name, 'command': command, 'started_utc': utc(), 'input_state_hashes': state_files}
write_json(output / (name + '_run.json'), record)
with (output / (name + '.log')).open('w') as stream:
@@ -144,6 +146,16 @@ def main():
record['timed_out'] = True
record['exit_code'] = None
record.update(seconds=time.monotonic() - start, finished_utc=utc())
cpu_end = resource.getrusage(resource.RUSAGE_CHILDREN)
# Keep independent clocks: suspend can affect elapsed clocks differently,
# and rescaling solver phase timings would hide that uncertainty.
record['utc_elapsed_seconds'] = (
datetime.datetime.fromisoformat(record['finished_utc']) -
datetime.datetime.fromisoformat(record['started_utc'])).total_seconds()
record['utc_minus_monotonic_seconds'] = record['utc_elapsed_seconds'] - record['seconds']
record['child_user_cpu_seconds'] = cpu_end.ru_utime - cpu_start.ru_utime
record['child_system_cpu_seconds'] = cpu_end.ru_stime - cpu_start.ru_stime
record['child_cpu_seconds'] = record['child_user_cpu_seconds'] + record['child_system_cpu_seconds']
record['output_hashes'] = {
str(path.relative_to(folder)): digest(path)
for path in sorted(folder.rglob('*'))