chiark / gitweb /
soak: Track total steps and steps within checkpoint separately.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 6 Sep 2024 19:55:44 +0000 (20:55 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 6 Sep 2024 20:49:35 +0000 (21:49 +0100)
Much less awful than adjusting `nsteps'.

soak

diff --git a/soak b/soak
index 79d4b61888278f3b1004aa62744d904770b3c8f7..6b90d0f59ecd6188fb3aa9c845cbd50ec09024e4 100755 (executable)
--- a/soak
+++ b/soak
@@ -228,7 +228,7 @@ KID = SUB.Popen(OPTS.testprog, stdin = SUB.PIPE, stdout = SUB.PIPE)
 
 def fail(msg):
   SYS.stderr.write("%s: FAILED: %s\n" % (PROG, msg))
-  SYS.stderr.write("%s:   step = %d\n" % (PROG, STEP))
+  SYS.stderr.write("%s:   step = %d\n" % (PROG, CSTEP))
   KID.stdin.close()
   KID.stdout.close()
   rc = KID.wait()
@@ -276,10 +276,10 @@ for lv in ST.stack:
 put("= %s\n" % ST.cur.tree)
 dump_tree()
 
-STEP = 0; nsteps = OPTS.nsteps
+STEP = CSTEP = 0; nsteps = OPTS.nsteps
 ch = choices()
 while nsteps is None or STEP < nsteps:
-  if OPTS.sync: SYS.stdout.write("\n;; step %d\n" % STEP)
+  if OPTS.sync: SYS.stdout.write("\n;; step %d\n" % CSTEP)
   op = ch.choose(ST.rand)
 
   if op == "addrm1":
@@ -391,14 +391,13 @@ while nsteps is None or STEP < nsteps:
   else:
     raise ValueError("unexpected operation `%s'" % op)
 
-  STEP += 1
+  STEP += 1; CSTEP += 1
   dump_tree()
-  if OPTS.sync or STEP == OPTS.ckpt_steps: check_tree()
-  if STEP == OPTS.ckpt_steps:
+  if OPTS.sync or CSTEP == OPTS.ckpt_steps: check_tree()
+  if CSTEP == OPTS.ckpt_steps:
     snapshot()
     ST.write_ckpt()
-    STEP = 0; OPTS.sync = False
-    if nsteps is not None: nsteps -= OPTS.ckpt_steps
+    CSTEP = 0; OPTS.sync = False
 
 while True:
   check_tree()