Time review more precisely and save to JournalFile
dkl9

dkl9 commited on 2024-265 15:30:44
Showing 1 changed files, with 19 additions and 9 deletions.

... ...
@@ -156,6 +156,7 @@ local function fn(config, deck, deckfname)
156 156
             table.insert(editqueue, ip)
157 157
         else
158 158
             if sc == 0 then
159
+                rt[#rt] = -rt[#rt]
159 160
                 lrc = lrc + 1
160 161
             end
161 162
             review.update(deck[ip[1]].pr[ip[2]], st, sc, config)
... ...
@@ -166,27 +167,36 @@ local function fn(config, deck, deckfname)
166 167
             break
167 168
         end
168 169
     end
169
-    if #ctrt > 0 then
170
-        local acr = math.min(#ctrt, climn)
170
+    if climn > 0 then
171 171
         local endt = time()
172 172
         io.write(string.format(
173
-            "Reviewed %d prompts in %f seconds\n",
174
-            acr, endt - start
173
+            "Reviewed %d prompts in %.1f seconds\n",
174
+            climn, endt - start
175 175
         ))
176 176
         local s
177 177
         if lrc == 1 then s = "" else s = "s" end
178 178
         io.write(string.format(
179
-            "(%d lapse%s, %f seconds per card)\n",
180
-            lrc, s, (endt - start) / acr
179
+            "(%d lapse%s, %.2f seconds per card)\n",
180
+            lrc, s, (endt - start) / climn
181 181
         ))
182 182
         local trt = 0
183 183
         for _, x in ipairs(rt) do
184
-            trt = trt + x
184
+            trt = trt + math.abs(x)
185 185
         end
186 186
         io.write(string.format(
187
-            "Average %f seconds for recall per card\n",
188
-            trt / acr
187
+            "Average %.2f seconds for recall per card\n",
188
+            trt / climn
189
+        ))
190
+        local jf = config:get("JournalFile")
191
+        if jf then
192
+            jf = os.getenv("HOME") .. "/" .. jf
193
+            local fh = io.open(jf, "a")
194
+            fh:write(string.format(
195
+                "%s memrc=%d memrd.mean=%.2f\n",
196
+                os.date("%Y-%jT%H:%M:%S"), climn, trt / climn
189 197
             ))
198
+            fh:close()
199
+        end
190 200
     end
191 201
     if #editqueue > 0 then
192 202
         io.write(string.format("The following cards are marked for correction:\n"))
193 203