Add profiling for machinery.

This commit is contained in:
Rob Nelson
2014-04-21 18:04:45 -07:00
parent 2fc121e83d
commit 397c512728
4 changed files with 33 additions and 3 deletions

View File

@@ -11,6 +11,11 @@ var/global/last_tick_duration = 0
var/global/air_processing_killed = 0
var/global/pipe_processing_killed = 0
#ifdef PROFILE_MACHINES
// /type = time this tick
var/list/machine_profiling=list()
#endif
datum/controller/game_controller
var/processing = 0
var/breather_ticks = 2 //a somewhat crude attempt to iron over the 'bumps' caused by high-cpu use by letting the MC have a breather for this many ticks after every loop
@@ -265,17 +270,23 @@ datum/controller/game_controller/proc/processMobs()
active_diseases -= Disease
/datum/controller/game_controller/proc/processMachines()
#ifdef PROFILE_MACHINES
machine_profiling.Cut()
#endif
for (var/obj/machinery/Machinery in machines)
if (Machinery && Machinery.loc)
last_thing_processed = Machinery.type
var/start = world.timeofday
if(Machinery.process() != PROCESS_KILL)
if (Machinery) // Why another check?
if (Machinery.use_power)
Machinery.auto_use_power()
#ifdef PROFILE_MACHINES
if(!(Machinery.type in machine_profiling))
machine_profiling[Machinery.type] = 0
machine_profiling[Machinery.type] += world.timeofday - start
#endif
continue
Machinery.removeAtProcessing()
/datum/controller/game_controller/proc/processObjects()

View File

@@ -152,6 +152,9 @@ var/list/admin_verbs_debug = list(
/client/proc/qdel_toggle, // /vg/
/client/proc/cmd_admin_dump_instances, // /vg/
/client/proc/disable_bloodvirii, // /vg/
#ifdef PROFILE_MACHINES
/client/proc/cmd_admin_dump_macprofile,
#endif
)
var/list/admin_verbs_possess = list(
/proc/possess,

View File

@@ -1125,6 +1125,21 @@ Pressure: [env.return_pressure()]"}
usr << "\blue Dumped to instances.csv."
#ifdef PROFILE_MACHINES
/client/proc/cmd_admin_dump_macprofile()
set category = "Debug"
set name = "Dump Machine Profiling"
var/F = file("machine_profiling.csv")
fdel(F)
F << "type,nanoseconds"
for(var/typepath in machine_profiling)
var/ns = machine_profiling[typepath]
F << "[typepath],[ns]"
usr << "\blue Dumped to machine_profiling.csv."
#endif
/client/proc/gib_money()
set category = "Fun"
set name = "Dispense Money"

View File

@@ -1,6 +1,7 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
#define DEBUG
#define PROFILE_MACHINES // Disable when not debugging.
#define PI 3.1415