Skip to content

Commit

Permalink
Optimize PDA painter init, improve init tracking (BeeStation#10438)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow authored and DrDuckedGoose committed May 11, 2024
1 parent 6bffe1c commit 145c4b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
5 changes: 4 additions & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
#define ZMIMIC_LIGHT_BLEED

/// If this is uncommented, will profile mapload atom initializations
// #define PROFILE_MAPLOAD_INIT_ATOM
//#define PROFILE_MAPLOAD_INIT_ATOM
#ifdef PROFILE_MAPLOAD_INIT_ATOM
#warn PROFILE_MAPLOAD_INIT_ATOM creates very large profiles, do not leave this on!
#endif

//#define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between

Expand Down
7 changes: 4 additions & 3 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SUBSYSTEM_DEF(atoms)

#ifdef PROFILE_MAPLOAD_INIT_ATOM
#define PROFILE_INIT_ATOM_BEGIN(...) var/__profile_stat_time = TICK_USAGE
#define PROFILE_INIT_ATOM_END(atom) mapload_init_times[##atom.type] += TICK_USAGE_TO_MS(__profile_stat_time)
#define PROFILE_INIT_ATOM_END(atom) mapload_init_times += list(list(##atom.type, TICK_USAGE_TO_MS(__profile_stat_time)))
#else
#define PROFILE_INIT_ATOM_BEGIN(...)
#define PROFILE_INIT_ATOM_END(...)
Expand Down Expand Up @@ -90,8 +90,9 @@ SUBSYSTEM_DEF(atoms)
#ifdef PROFILE_MAPLOAD_INIT_ATOM
var/list/lines = list()
lines += "Atom Path,Initialisation Time (ms)"
for (var/atom_type in mapload_init_times)
var/time = mapload_init_times[atom_type]
for (var/data in mapload_init_times)
var/atom_type = data[1]
var/time = data[2]
lines += "[atom_type],[time]"
rustg_file_write(jointext(lines, "\n"), "[GLOB.log_directory]/init_times.csv")
#endif
Expand Down
18 changes: 0 additions & 18 deletions code/game/machinery/PDApainter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"Misc: Prisoner" = "pda-prisoner"
)
max_integrity = 200
var/list/colorlist = list()

/obj/machinery/pdapainter/on_emag(mob/user)
..()
Expand Down Expand Up @@ -83,23 +82,6 @@

return

/obj/machinery/pdapainter/Initialize(mapload)
. = ..()
var/list/blocked = list(
/obj/item/modular_computer/tablet/pda/heads,
/obj/item/modular_computer/tablet/pda/clear,
/obj/item/modular_computer/tablet/pda/syndicate,
/obj/item/modular_computer/tablet/pda/chameleon,
/obj/item/modular_computer/tablet/pda/chameleon/broken)

for(var/P in typesof(/obj/item/modular_computer/tablet/pda) - blocked)
var/obj/item/modular_computer/tablet/pda/D = new P

//D.name = "PDA Style [colorlist.len+1]" //Gotta set the name, otherwise it all comes up as "PDA"
D.name = D.icon_state //PDAs don't have unique names, but using the sprite names works.

src.colorlist += D

/obj/machinery/pdapainter/Destroy()
QDEL_NULL(storedpda)
QDEL_NULL(storedid)
Expand Down

0 comments on commit 145c4b9

Please sign in to comment.