Software / code / prosody
Comparison
plugins/mod_admin_shell.lua @ 11478:c0c4431ab27b
mod_admin_shell: Sort timers by time in debug:timers()
Easier to see which timers are happening soon vs further in the future
if they are in some sensible order.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 23 Mar 2021 21:52:07 +0100 |
| parent | 11365:5eb817cdd5cd |
| child | 11504:1f700f5f62cb |
comparison
equal
deleted
inserted
replaced
| 11477:c90ef8745779 | 11478:c0c4431ab27b |
|---|---|
| 1305 print("-- net.server.timer"); | 1305 print("-- net.server.timer"); |
| 1306 h = server.timer.add_task.timers; | 1306 h = server.timer.add_task.timers; |
| 1307 normalize_time = server.timer.to_absolute_time or normalize_time; | 1307 normalize_time = server.timer.to_absolute_time or normalize_time; |
| 1308 end | 1308 end |
| 1309 if h then | 1309 if h then |
| 1310 local timers = {}; | |
| 1310 for i, id in ipairs(h.ids) do | 1311 for i, id in ipairs(h.ids) do |
| 1311 local t, cb = h.priorities[i], h.items[id]; | 1312 local t, cb = h.priorities[i], h.items[id]; |
| 1312 if not params then | 1313 if not params then |
| 1313 local param = cb.param; | 1314 local param = cb.param; |
| 1314 if param then | 1315 if param then |
| 1317 cb = cb.timer_callback or cb; | 1318 cb = cb.timer_callback or cb; |
| 1318 end | 1319 end |
| 1319 elseif params[id] then | 1320 elseif params[id] then |
| 1320 cb = params[id].callback or cb; | 1321 cb = params[id].callback or cb; |
| 1321 end | 1322 end |
| 1322 print(format_time(t), cb); | 1323 table.insert(timers, { format_time(t), cb }); |
| 1324 end | |
| 1325 table.sort(timers, function (a, b) return a[1] < b[1] end); | |
| 1326 for _, t in ipairs(timers) do | |
| 1327 print(t[1], t[2]) | |
| 1323 end | 1328 end |
| 1324 end | 1329 end |
| 1325 if server.event_base then | 1330 if server.event_base then |
| 1326 local count = 0; | 1331 local count = 0; |
| 1327 for _, v in pairs(debug.getregistry()) do | 1332 for _, v in pairs(debug.getregistry()) do |