dkl9 commited on 2024-258 15:36:33
Showing 1 changed files, with 29 additions and 7 deletions.
| ... | ... |
@@ -1,3 +1,14 @@ |
| 1 |
+local posix = require("posix")
|
|
| 2 |
+ |
|
| 3 |
+local function time() |
|
| 4 |
+ if posix then |
|
| 5 |
+ local s, ns = posix.clock_gettime() |
|
| 6 |
+ return s + ns / 10^9 |
|
| 7 |
+ else |
|
| 8 |
+ return os.time() |
|
| 9 |
+ end |
|
| 10 |
+end |
|
| 11 |
+ |
|
| 1 | 12 |
--[[ |
| 2 | 13 |
show progress thru a review session, conditioned on the user |
| 3 | 14 |
configuring that to happen |
| ... | ... |
@@ -108,7 +119,8 @@ local function fn(config, deck, deckfname) |
| 108 | 119 |
climn = math.min(climn, #ctrt) |
| 109 | 120 |
local lrc = 0 |
| 110 | 121 |
local editqueue = {}
|
| 111 |
- local start = os.time() |
|
| 122 |
+ local start = time() |
|
| 123 |
+ local rt = {}
|
|
| 112 | 124 |
-- review prompts in this session's set |
| 113 | 125 |
for ind, ip in ipairs(ctrt) do |
| 114 | 126 |
if ind > climn then |
| ... | ... |
@@ -116,10 +128,12 @@ local function fn(config, deck, deckfname) |
| 116 | 128 |
end |
| 117 | 129 |
local pr = deck[ip[1]].pr[ip[2]] |
| 118 | 130 |
local pst = pr:text() |
| 119 |
- local st = os.time() |
|
| 131 |
+ local st = time() |
|
| 120 | 132 |
imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", ind, climn, config, true)
|
| 121 | 133 |
io.write("\n")
|
| 134 |
+ table.insert(rt, time()) |
|
| 122 | 135 |
io.read("l")
|
| 136 |
+ rt[#rt] = time() - rt[#rt] |
|
| 123 | 137 |
clear() |
| 124 | 138 |
imgify( |
| 125 | 139 |
pst:gsub("%%A", "\x1b[1m" .. (pr:ans():gsub("%%", "%%%%")) .. "\x1b[0m"),
|
| ... | ... |
@@ -153,17 +167,25 @@ local function fn(config, deck, deckfname) |
| 153 | 167 |
end |
| 154 | 168 |
end |
| 155 | 169 |
if #ctrt > 0 then |
| 156 |
- local endt = os.time() |
|
| 170 |
+ local acr = math.min(#ctrt, climn) |
|
| 171 |
+ local endt = time() |
|
| 157 | 172 |
io.write(string.format( |
| 158 |
- "Reviewed %d prompts in %d seconds\n", |
|
| 159 |
- math.min(#ctrt, climn), |
|
| 160 |
- endt - start |
|
| 173 |
+ "Reviewed %d prompts in %f seconds\n", |
|
| 174 |
+ acr, endt - start |
|
| 161 | 175 |
)) |
| 162 | 176 |
local s |
| 163 | 177 |
if lrc == 1 then s = "" else s = "s" end |
| 164 | 178 |
io.write(string.format( |
| 165 | 179 |
"(%d lapse%s, %f seconds per card)\n", |
| 166 |
- lrc, s, (endt - start) / math.min(#ctrt, climn) |
|
| 180 |
+ lrc, s, (endt - start) / acr |
|
| 181 |
+ )) |
|
| 182 |
+ local trt = 0 |
|
| 183 |
+ for _, x in ipairs(rt) do |
|
| 184 |
+ trt = trt + x |
|
| 185 |
+ end |
|
| 186 |
+ io.write(string.format( |
|
| 187 |
+ "Average %f seconds for recall per card\n", |
|
| 188 |
+ trt / acr |
|
| 167 | 189 |
)) |
| 168 | 190 |
end |
| 169 | 191 |
if #editqueue > 0 then |
| 170 | 192 |