Files
Letter NandGitHub 351af0bb8c random backend updates (#7061)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
title

## Changelog

🆑
fix: world_topic status host is correct now
code: updated progressbar
code: updated stack trace
code: updated callback
code: updated weakref
code: updated topic request, now supports returning json format
code: datum browser doesnt hold atom owner directly
code: updated stat tracking (debugging, not player stat)
admin: updated del-all verbs
admin: allow f12 browser inspect (516 only)
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2025-04-05 12:31:33 -07:00

68 lines
2.7 KiB
Plaintext

#define STAT_ENTRY_TIME 1
#define STAT_ENTRY_COUNT 2
#define STAT_ENTRY_LENGTH 2
#define STAT_START_STOPWATCH var/STAT_STOP_WATCH = TICK_USAGE
#define STAT_STOP_STOPWATCH var/STAT_TIME = TICK_USAGE_TO_MS(STAT_STOP_WATCH)
#define STAT_LOG_ENTRY(entrylist, entryname) \
var/list/STAT_ENTRY = entrylist[entryname] || (entrylist[entryname] = new /list(STAT_ENTRY_LENGTH));\
STAT_ENTRY[STAT_ENTRY_TIME] += STAT_TIME;\
STAT_ENTRY[STAT_ENTRY_COUNT] += 1;
// Cost tracking macros, to be used in one proc. If you're using this raw you'll want to use global lists
// If you don't you'll need another way of reading it
#define INIT_COST(costs, counting) \
var/list/_costs = costs; \
var/list/_counting = counting; \
var/_usage = TICK_USAGE;
// STATIC cost tracking macro. Uses static lists instead of the normal global ones
// Good for debug stuff, and for running before globals init
#define INIT_COST_STATIC(...) \
var/static/list/hidden_static_list_for_fun1 = list(); \
var/static/list/hidden_static_list_for_fun2 = list(); \
INIT_COST(hidden_static_list_for_fun1, hidden_static_list_for_fun2)
// Cost tracking macro for global lists, prevents erroring if GLOB has not yet been initialized
#define INIT_COST_GLOBAL(costs, counting) \
INIT_COST_STATIC() \
if(GLOB){\
costs = hidden_static_list_for_fun1; \
counting = hidden_static_list_for_fun2 ; \
} \
_usage = TICK_USAGE;
#define SET_COST(category) \
do { \
var/_cost = TICK_USAGE; \
_costs[category] += TICK_DELTA_TO_MS(_cost - _usage);\
_counting[category] += 1; \
} while(FALSE); \
_usage = TICK_USAGE;
#define SET_COST_LINE(...) SET_COST("[__LINE__]")
/// A quick helper for running the code as a statement and profiling its cost.
/// For example, `SET_COST_STMT(var/x = do_work())`
#define SET_COST_STMT(code...) ##code; SET_COST("[__LINE__] - [#code]")
#define EXPORT_STATS_TO_JSON_LATER(filename, costs, counts) EXPORT_STATS_TO_FILE_LATER(filename, costs, counts, stat_tracking_export_to_json_later)
#define EXPORT_STATS_TO_CSV_LATER(filename, costs, counts) EXPORT_STATS_TO_FILE_LATER(filename, costs, counts, stat_tracking_export_to_csv_later)
#define EXPORT_STATS_TO_FILE_LATER(filename, costs, counts, proc) \
do { \
var/static/last_export = 0; \
/* Need to always run if we haven't yet, since this code can be placed ANYWHERE */ \
if (world.time - last_export > 1.1 SECONDS || (last_export == 0)) { \
last_export = world.time; \
/* spawn() is used here because this is often used to track init times, where timers act oddly. */ \
/* I was making timers and even after init times were complete, the timers didn't run :shrug: */ \
spawn (1 SECONDS) { \
##proc(filename, costs, counts); \
} \
} \
} while (FALSE); \
_usage = TICK_USAGE;