mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 19:44:09 +01:00
Timer Type Tracking (#18803)
* Timer Type Tracking * Active bucket checking
This commit is contained in:
@@ -548,6 +548,77 @@ SUBSYSTEM_DEF(timer)
|
||||
else
|
||||
. = "[callBack.object.type]"
|
||||
|
||||
GLOBAL_LIST_EMPTY(timers_by_type)
|
||||
// Allows us to track what types generate the most timers. Just invokes the global addtimer
|
||||
/datum/proc/addtimer(datum/callback/callback, wait = 0, flags = 0)
|
||||
var/tt = "[type]"
|
||||
if(tt in GLOB.timers_by_type)
|
||||
GLOB.timers_by_type[tt]++
|
||||
else
|
||||
GLOB.timers_by_type[tt] = 1
|
||||
return global.addtimer(callback, wait, flags)
|
||||
|
||||
/**
|
||||
* Opens a log of timers
|
||||
*
|
||||
* In-round ability to view what has created a timer, and how many times a timer for that path has been created
|
||||
*/
|
||||
/client/proc/timer_log()
|
||||
set name = "View Timer Log"
|
||||
set category = "Debug"
|
||||
set desc = "Shows the log of what types created timers this round"
|
||||
|
||||
if(!check_rights(R_DEBUG))
|
||||
return
|
||||
|
||||
var/list/sorted = sortTim(GLOB.timers_by_type, cmp=/proc/cmp_numeric_dsc, associative = TRUE)
|
||||
var/list/text = list("<h1>Timer Log</h1>", "<ul>")
|
||||
for(var/key in sorted)
|
||||
text += "<li>[key] - [sorted[key]]</li>"
|
||||
|
||||
text += "</ul>"
|
||||
usr << browse(text.Join(), "window=timerlog")
|
||||
|
||||
/client/proc/debug_timers()
|
||||
set name = "Debug Timers"
|
||||
set category = "Debug"
|
||||
set desc = "Shows currently active timers, grouped by callback"
|
||||
|
||||
var/list/timers = list()
|
||||
for(var/id in SStimer.timer_id_dict)
|
||||
var/datum/timedevent/T = SStimer.timer_id_dict[id]
|
||||
var/cbtxt = "[T.callBack.delegate]"
|
||||
if(cbtxt in timers)
|
||||
timers[cbtxt]++
|
||||
else
|
||||
timers[cbtxt] = 1
|
||||
|
||||
|
||||
var/list/sorted = sortTim(timers, cmp=/proc/cmp_numeric_dsc, associative = TRUE)
|
||||
var/list/text = list("<h1>All active timers sorted by callback</h1>", "<ul>")
|
||||
for(var/key in sorted)
|
||||
text += "<li>[key] - [sorted[key]]</li>"
|
||||
|
||||
text += "</ul>"
|
||||
|
||||
var/list/timers2 = list()
|
||||
|
||||
for(var/datum/timedevent/T in SStimer.bucket_list)
|
||||
var/cbtxt = "[T.callBack.delegate]"
|
||||
if(cbtxt in timers2)
|
||||
timers2[cbtxt]++
|
||||
else
|
||||
timers2[cbtxt] = 1
|
||||
|
||||
text += "<h1>All buckets, sorted by callback</h1><ul>"
|
||||
var/list/sorted2 = sortTim(timers2, cmp=/proc/cmp_numeric_dsc, associative = TRUE)
|
||||
for(var/key in sorted2)
|
||||
text += "<li>[key] - [sorted2[key]]</li>"
|
||||
|
||||
text += "</ul>"
|
||||
usr << browse(text.Join(), "window=timerdebug")
|
||||
|
||||
|
||||
/**
|
||||
* Create a new timer and insert it in the queue.
|
||||
* You should not call this directly, and should instead use the addtimer macro, which includes source information.
|
||||
|
||||
Reference in New Issue
Block a user