mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Performance counter macros
This commit is contained in:
parent
45dbb0524c
commit
59db61e192
@ -200,6 +200,9 @@ PREP(logDisplays);
|
||||
PREP(monitor);
|
||||
PREP(showUser);
|
||||
|
||||
PREP(dumpPerformanceCounters);
|
||||
PREP(dumpArray);
|
||||
|
||||
// ACE_CuratorFix
|
||||
PREP(addCuratorUnloadEventhandler);
|
||||
PREP(fixCrateContent);
|
||||
@ -228,6 +231,9 @@ PREP(hashListSelect);
|
||||
PREP(hashListSet);
|
||||
PREP(hashListPush);
|
||||
|
||||
//Debug
|
||||
ACE_COUNTERS = [];
|
||||
|
||||
// Load settings
|
||||
if (isServer) then {
|
||||
call FUNC(loadSettingsOnServer);
|
||||
|
25
addons/common/functions/fnc_dumpArray.sqf
Normal file
25
addons/common/functions/fnc_dumpArray.sqf
Normal file
@ -0,0 +1,25 @@
|
||||
//fnc_dumpArray.sqf
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_var", "_depth", "_pad", "_i", "_x"];
|
||||
|
||||
_var = _this select 0;
|
||||
_depth = _this select 1;
|
||||
_pad = "";
|
||||
for "_i" from 0 to _depth do {
|
||||
_pad = _pad + toString [9];
|
||||
};
|
||||
_depth = _depth + 1;
|
||||
if(IS_ARRAY(_var)) then {
|
||||
if((count _var) > 0) then {
|
||||
diag_log text format["%1[", _pad];
|
||||
{
|
||||
[_x, _depth] call FUNC(dumpArray);
|
||||
} forEach _var;
|
||||
diag_log text format["%1],", _pad];
|
||||
} else {
|
||||
diag_log text format["%1[],", _pad];
|
||||
};
|
||||
} else {
|
||||
diag_log text format["%1%2", _pad, [_var] call FUNC(formatVar)];
|
||||
};
|
73
addons/common/functions/fnc_dumpPerformanceCounters.sqf
Normal file
73
addons/common/functions/fnc_dumpPerformanceCounters.sqf
Normal file
@ -0,0 +1,73 @@
|
||||
//fnc_dumpPerformanceCounters.sqf
|
||||
#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
/*
|
||||
diag_log text format["REGISTERED ACE PFH HANDLERS"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
if(!isNil "ACE_PFH") then {
|
||||
{
|
||||
private["_pfh"];
|
||||
_pfh = _x select 0;
|
||||
diag_log text format["Registered PFH: id=%1, %1:%2", (_pfh select 0), (_pfh select 1), (_pfh select 2) ];
|
||||
} forEach ACE_PFH;
|
||||
};*/
|
||||
|
||||
diag_log text format["ACE COUNTER RESULTS"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
{
|
||||
private["_counterEntry", "_iter", "_total", "_count", "_delta", "_averageResult"];
|
||||
_counterEntry = _x;
|
||||
_iter = 0;
|
||||
_total = 0;
|
||||
_count = 0;
|
||||
_averageResult = 0;
|
||||
if( (count _counterEntry) > 3) then {
|
||||
// calc
|
||||
{
|
||||
if(_iter > 2) then {
|
||||
_count = _count + 1;
|
||||
_delta = (_x select 1) - (_x select 0);
|
||||
|
||||
_total = _total + _delta;
|
||||
};
|
||||
_iter = _iter + 1;
|
||||
} forEach _counterEntry;
|
||||
|
||||
// results
|
||||
_averageResult = (_total / _count) * 1000;
|
||||
|
||||
// dump results
|
||||
diag_log text format["%1: Average: %2s / %3 = %4ms", (_counterEntry select 0), _total, _count, _averageResult];
|
||||
} else {
|
||||
diag_log text format["%1: No results", (_counterEntry select 0) ];
|
||||
};
|
||||
} forEach ACE_COUNTERS;
|
||||
|
||||
/*
|
||||
// Dump PFH Trackers
|
||||
diag_log text format["ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
{
|
||||
private["_delay"];
|
||||
_delay = _x select 2;
|
||||
//if(_delay > 0) then { _delay = _delay / 1000; };
|
||||
|
||||
diag_log text format["%1: %2s, delay=%3, handle=%4",(_x select 0), _delay, (_x select 3), (_x select 4)];
|
||||
} forEach ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER;
|
||||
|
||||
// Dump PFH Trackers
|
||||
diag_log text format["ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
{
|
||||
private["_delta"];
|
||||
_delta = _x select 1;
|
||||
//if(_delta > 0) then { _delta = _delta / 1000; };
|
||||
diag_log text format[" DELTA: %1s", _delta];
|
||||
} forEach ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER;
|
||||
|
||||
//{
|
||||
//
|
||||
//} forEach ACRE_EXCESSIVE_FRAME_TRACKER;
|
||||
|
||||
*/
|
46
addons/main/script_debug.hpp
Normal file
46
addons/main/script_debug.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
STACK TRACING
|
||||
**/
|
||||
//#define ENABLE_CALLSTACK
|
||||
|
||||
#ifdef ENABLE_CALLSTACK
|
||||
|
||||
#define CALLSTACK(function) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'ANON', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'ANON'; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define CALLSTACK_NAMED(function, functionName) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, functionName, _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = functionName; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define DUMPSTACK ([__FILE__, __LINE__] call ACE_DUMPSTACK_FNC)
|
||||
|
||||
#define FUNC(var1) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(ADDON,fnc,var1)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(ADDON,fnc,var1)'; _ret = _this call TRIPLES(ADDON,fnc,var1); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define EFUNC(var1,var2) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)'; _ret = _this call TRIPLES(DOUBLES(PREFIX,var1),fnc,var2); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
|
||||
#else
|
||||
#define CALLSTACK(function) function
|
||||
#define CALLSTACK_NAMED(function, functionName) function
|
||||
#define DUMPSTACK
|
||||
|
||||
#define FUNC(var1) TRIPLES(ADDON,fnc,var1)
|
||||
#define EFUNC(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
PERFORMANCE COUNTERS SECTION
|
||||
**/
|
||||
//#define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef ENABLE_PERFORMANCE_COUNTERS
|
||||
#define ADDPFH(function, timing, args) call { _ret = [function, timing, args, #function] call EFUNC(sys_sync,perFrame_add); if(isNil "ACE_PFH" ) then { ACE_PFH=[]; }; ACE_PFH pushBack [[_ret, __FILE__, __LINE__], [function, timing, args]]; _ret }
|
||||
|
||||
#define CREATE_COUNTER(x) if(isNil "ACE_COUNTERS" ) then { ACE_COUNTERS=[]; }; GVAR(DOUBLES(x,counter))=[]; GVAR(DOUBLES(x,counter)) set[0, QUOTE(GVAR(DOUBLES(x,counter)))]; GVAR(DOUBLES(x,counter)) set[1, diag_tickTime]; ACE_COUNTERS pushBack GVAR(DOUBLES(x,counter));
|
||||
#define BEGIN_COUNTER(x) if(isNil QUOTE(GVAR(DOUBLES(x,counter)))) then { CREATE_COUNTER(x) }; GVAR(DOUBLES(x,counter)) set[2, diag_tickTime];
|
||||
#define END_COUNTER(x) GVAR(DOUBLES(x,counter)) pushBack [(GVAR(DOUBLES(x,counter)) select 2), diag_tickTime];
|
||||
|
||||
#define DUMP_COUNTERS ([__FILE__, __LINE__] call ACE_DUMPCOUNTERS_FNC)
|
||||
#else
|
||||
#define ADDPFH(function, timing, args) [function, timing, args, #function] call EFUNC(sys_sync,perFrame_add)
|
||||
|
||||
#define CREATE_COUNTER(x) /* disabled */
|
||||
#define BEGIN_COUNTER(x) /* disabled */
|
||||
#define END_COUNTER(x) /* disabled */
|
||||
#define DUMP_COUNTERS /* disabled */
|
||||
#endif
|
@ -223,26 +223,6 @@
|
||||
|
||||
#define PREP_MODULE(folder) [] call compile preprocessFileLineNumbers QUOTE(PATHTOF(folder\__PREP__.sqf))
|
||||
|
||||
|
||||
#ifdef ENABLE_CALLSTACK
|
||||
#define CALLSTACK(function) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'ANON', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'ANON'; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define CALLSTACK_NAMED(function, functionName) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, functionName, _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = functionName; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define DUMPSTACK ([__FILE__, __LINE__] call ACE_DUMPSTACK_FNC)
|
||||
|
||||
#define FUNC(var1) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(ADDON,fnc,var1)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(ADDON,fnc,var1)'; _ret = _this call TRIPLES(ADDON,fnc,var1); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
#define EFUNC(var1,var2) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)'; _ret = _this call TRIPLES(DOUBLES(PREFIX,var1),fnc,var2); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;}
|
||||
|
||||
#else
|
||||
#define CALLSTACK(function) function
|
||||
#define CALLSTACK_NAMED(function, functionName) function
|
||||
#define DUMPSTACK
|
||||
|
||||
#define FUNC(var1) TRIPLES(ADDON,fnc,var1)
|
||||
#define EFUNC(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define HASH_CREATE ([] call EFUNC(common,hashCreate))
|
||||
#define HASH_SET(hash, key, val) ([hash, key, val, __FILE__, __LINE__] call EFUNC(common,hashSet))
|
||||
#define HASH_GET(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashGet))
|
||||
@ -254,3 +234,5 @@
|
||||
#define HASHLIST_SELECT(hashList, index) ([hashList, index, __FILE__, __LINE__] call EFUNC(common,hashListSelect))
|
||||
#define HASHLIST_SET(hashList, index, value) ([hashList, index, value, __FILE__, __LINE__] call EFUNC(common,hashListSet))
|
||||
#define HASHLIST_PUSH(hashList, value) ([hashList, value, __FILE__, __LINE__] call EFUNC(common,hashListPush))
|
||||
|
||||
#include "script_debug.hpp"
|
Loading…
Reference in New Issue
Block a user