mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 04:30:44 +01:00
Add check timer sources debug command (#108)
Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com> Co-authored-by: Azarak <azarak10@gmail.com>
This commit is contained in:
co-authored by
Jared-Fogle
Azarak
parent
90eaf768bd
commit
2afc8586e6
@@ -174,6 +174,7 @@ GLOBAL_PROTECT(admin_verbs_debug)
|
||||
/datum/admins/proc/view_refs,
|
||||
/datum/admins/proc/view_del_failures,
|
||||
#endif
|
||||
/client/proc/check_timer_sources
|
||||
)
|
||||
GLOBAL_LIST_INIT(admin_verbs_possess, list(/proc/possess, /proc/release))
|
||||
GLOBAL_PROTECT(admin_verbs_possess)
|
||||
|
||||
@@ -889,3 +889,63 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
|
||||
return
|
||||
if(alert(usr, "Are you absolutely sure you want to reload the configuration from the default path on the disk, wiping any in-round modificatoins?", "Really reset?", "No", "Yes") == "Yes")
|
||||
config.admin_reload()
|
||||
|
||||
/// A debug verb to check the sources of currently running timers
|
||||
/client/proc/check_timer_sources()
|
||||
set category = "Debug"
|
||||
set name = "Check Timer Sources"
|
||||
set desc = "Checks the sources of the running timers"
|
||||
if (!check_rights(R_DEBUG))
|
||||
return
|
||||
|
||||
var/bucket_list_output = generate_timer_source_output(SStimer.bucket_list)
|
||||
var/second_queue = generate_timer_source_output(SStimer.second_queue)
|
||||
|
||||
usr << browse({"
|
||||
<h3>bucket_list</h3>
|
||||
[bucket_list_output]
|
||||
|
||||
<h3>second_queue</h3>
|
||||
[second_queue]
|
||||
"}, "window=check_timer_sources;size=700x700")
|
||||
|
||||
/proc/generate_timer_source_output(list/datum/timedevent/events)
|
||||
var/list/per_source = list()
|
||||
|
||||
// Collate all events and figure out what sources are creating the most
|
||||
for (var/_event in events)
|
||||
if (!_event)
|
||||
continue
|
||||
var/datum/timedevent/event = _event
|
||||
|
||||
do
|
||||
if (event.source)
|
||||
if (per_source[event.source] == null)
|
||||
per_source[event.source] = 1
|
||||
else
|
||||
per_source[event.source] += 1
|
||||
event = event.next
|
||||
while (event && event != _event)
|
||||
|
||||
// Now, sort them in order
|
||||
var/list/sorted = list()
|
||||
for (var/source in per_source)
|
||||
sorted += list(list("source" = source, "count" = per_source[source]))
|
||||
sorted = sortTim(sorted, .proc/cmp_timer_data)
|
||||
|
||||
// Now that everything is sorted, compile them into an HTML output
|
||||
var/output = "<table border='1'>"
|
||||
|
||||
for (var/_timer_data in sorted)
|
||||
var/list/timer_data = _timer_data
|
||||
output += {"<tr>
|
||||
<td><b>[timer_data["source"]]</b></td>
|
||||
<td>[timer_data["count"]]</td>
|
||||
</tr>"}
|
||||
|
||||
output += "</table>"
|
||||
|
||||
return output
|
||||
|
||||
/proc/cmp_timer_data(list/a, list/b)
|
||||
return b["count"] - a["count"]
|
||||
|
||||
Reference in New Issue
Block a user