mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
@@ -1,9 +1,7 @@
|
||||
#define PROFILER_FILENAME "profiler.json"
|
||||
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
#define SENDMAPS_FILENAME "sendmaps.json"
|
||||
GLOBAL_REAL_VAR(world_init_maptick_profiler) = world.Profile(PROFILE_RESTART, type = "sendmaps")
|
||||
#endif
|
||||
|
||||
|
||||
SUBSYSTEM_DEF(profiler)
|
||||
name = "Profiler"
|
||||
@@ -32,41 +30,22 @@ SUBSYSTEM_DEF(profiler)
|
||||
/datum/controller/subsystem/profiler/Shutdown()
|
||||
if(CONFIG_GET(flag/auto_profile))
|
||||
DumpFile()
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
world.Profile(PROFILE_CLEAR, type = "sendmaps")
|
||||
#endif
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/profiler/proc/StartProfiling()
|
||||
#if DM_BUILD < 1506
|
||||
stack_trace("Auto profiling unsupported on this byond version")
|
||||
CONFIG_SET(flag/auto_profile, FALSE)
|
||||
#else
|
||||
world.Profile(PROFILE_START)
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
world.Profile(PROFILE_START, type = "sendmaps")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/datum/controller/subsystem/profiler/proc/StopProfiling()
|
||||
#if DM_BUILD >= 1506
|
||||
world.Profile(PROFILE_STOP)
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
world.Profile(PROFILE_STOP, type = "sendmaps")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/datum/controller/subsystem/profiler/proc/DumpFile()
|
||||
#if DM_BUILD < 1506
|
||||
stack_trace("Auto profiling unsupported on this byond version")
|
||||
CONFIG_SET(flag/auto_profile, FALSE)
|
||||
#else
|
||||
var/timer = TICK_USAGE_REAL
|
||||
var/current_profile_data = world.Profile(PROFILE_REFRESH, format = "json")
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
var/current_sendmaps_data = world.Profile(PROFILE_REFRESH, type = "sendmaps", format="json")
|
||||
#endif
|
||||
fetch_cost = MC_AVERAGE(fetch_cost, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
CHECK_TICK
|
||||
|
||||
@@ -75,18 +54,13 @@ SUBSYSTEM_DEF(profiler)
|
||||
var/prof_file = file("[GLOB.log_directory]/[PROFILER_FILENAME]")
|
||||
if(fexists(prof_file))
|
||||
fdel(prof_file)
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
if(!length(current_sendmaps_data)) //Would be nice to have explicit proc to check this
|
||||
stack_trace("Warning, sendmaps profiling stopped manually before dump.")
|
||||
var/sendmaps_file = file("[GLOB.log_directory]/[SENDMAPS_FILENAME]")
|
||||
if(fexists(sendmaps_file))
|
||||
fdel(sendmaps_file)
|
||||
#endif
|
||||
|
||||
timer = TICK_USAGE_REAL
|
||||
WRITE_FILE(prof_file, current_profile_data)
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
WRITE_FILE(sendmaps_file, current_sendmaps_data)
|
||||
#endif
|
||||
write_cost = MC_AVERAGE(write_cost, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,6 @@ SUBSYSTEM_DEF(time_track)
|
||||
var/last_tick_realtime = 0
|
||||
var/last_tick_byond_time = 0
|
||||
var/last_tick_tickcount = 0
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
var/list/sendmaps_names_map = list(
|
||||
"SendMaps" = "send_maps",
|
||||
"SendMaps: Initial housekeeping" = "initial_house",
|
||||
@@ -41,19 +40,16 @@ SUBSYSTEM_DEF(time_track)
|
||||
"SendMaps: Per client: Map data: Look for movable changes: Loop through turfs in range" = "turfs_in_range",
|
||||
"SendMaps: Per client: Map data: Look for movable changes: Movables examined" = "movables_examined",
|
||||
)
|
||||
#endif
|
||||
|
||||
/datum/controller/subsystem/time_track/Initialize(start_timeofday)
|
||||
. = ..()
|
||||
GLOB.perf_log = "[GLOB.log_directory]/perf-[GLOB.round_id ? GLOB.round_id : "NULL"]-[SSmapping.config?.map_name].csv"
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
world.Profile(PROFILE_RESTART, type = "sendmaps")
|
||||
//Need to do the sendmaps stuff in its own file, since it works different then everything else
|
||||
var/list/sendmaps_shorthands = list()
|
||||
var/list/sendmaps_headers = list()
|
||||
for(var/proper_name in sendmaps_names_map)
|
||||
sendmaps_shorthands += sendmaps_names_map[proper_name]
|
||||
sendmaps_shorthands += "[sendmaps_names_map[proper_name]]_count"
|
||||
#endif
|
||||
sendmaps_headers += sendmaps_names_map[proper_name]
|
||||
sendmaps_headers += "[sendmaps_names_map[proper_name]]_count"
|
||||
log_perf(
|
||||
list(
|
||||
"time",
|
||||
@@ -80,13 +76,10 @@ SUBSYSTEM_DEF(time_track)
|
||||
"all_queries",
|
||||
"queries_active",
|
||||
"queries_standby"
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
) + sendmaps_shorthands
|
||||
#else
|
||||
)
|
||||
#endif
|
||||
) + sendmaps_headers
|
||||
)
|
||||
|
||||
|
||||
/datum/controller/subsystem/time_track/fire()
|
||||
|
||||
var/current_realtime = REALTIMEOFDAY
|
||||
@@ -108,7 +101,6 @@ SUBSYSTEM_DEF(time_track)
|
||||
last_tick_byond_time = current_byondtime
|
||||
last_tick_tickcount = current_tickcount
|
||||
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
var/sendmaps_json = world.Profile(PROFILE_REFRESH, type = "sendmaps", format="json")
|
||||
var/list/send_maps_data = json_decode(sendmaps_json)
|
||||
var/send_maps_sort = send_maps_data.Copy() //Doing it like this guarentees us a properly sorted list
|
||||
@@ -117,10 +109,14 @@ SUBSYSTEM_DEF(time_track)
|
||||
send_maps_sort[packet["name"]] = packet
|
||||
|
||||
var/list/send_maps_values = list()
|
||||
for(var/list/packet in send_maps_sort)
|
||||
for(var/entry_name in sendmaps_names_map)
|
||||
var/list/packet = send_maps_sort[entry_name]
|
||||
if(!packet) //If the entry does not have a value for us, just put in 0 for both
|
||||
send_maps_values += 0
|
||||
send_maps_values += 0
|
||||
continue
|
||||
send_maps_values += packet["value"]
|
||||
send_maps_values += packet["calls"]
|
||||
#endif
|
||||
|
||||
SSblackbox.record_feedback("associative", "time_dilation_current", 1, list("[SQLtime()]" = list("current" = "[time_dilation_current]", "avg_fast" = "[time_dilation_avg_fast]", "avg" = "[time_dilation_avg]", "avg_slow" = "[time_dilation_avg_slow]")))
|
||||
log_perf(
|
||||
@@ -149,23 +145,7 @@ SUBSYSTEM_DEF(time_track)
|
||||
SSdbcore.all_queries_num,
|
||||
SSdbcore.queries_active_num,
|
||||
SSdbcore.queries_standby_num
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
) + send_maps_values
|
||||
#else
|
||||
)
|
||||
#endif
|
||||
)
|
||||
|
||||
SSdbcore.reset_tracking()
|
||||
|
||||
#ifdef SENDMAPS_PROFILE
|
||||
/datum/controller/subsystem/time_track/proc/scream_maptick_data()
|
||||
var/current_profile_data = world.Profile(PROFILE_REFRESH, type = "sendmaps", format="json")
|
||||
log_world(current_profile_data)
|
||||
current_profile_data = json_decode(current_profile_data)
|
||||
var/output = ""
|
||||
for(var/list/entry in current_profile_data)
|
||||
output += "[entry["name"]],[entry["value"]],[entry["calls"]]\n"
|
||||
log_world(output)
|
||||
return output
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user