engine: server: register str64stats command that prints string pool usage statistics

This commit is contained in:
Alibek Omarov 2024-03-25 05:49:34 +03:00
parent d34fedea69
commit f6d489e038
3 changed files with 14 additions and 12 deletions

View File

@ -613,9 +613,7 @@ string_t SV_MakeString( const char *szValue );
const char *SV_GetString( string_t iString ); const char *SV_GetString( string_t iString );
void SV_SetStringArrayMode( qboolean dynamic ); void SV_SetStringArrayMode( qboolean dynamic );
void SV_EmptyStringPool( void ); void SV_EmptyStringPool( void );
#ifdef XASH_64BIT
void SV_PrintStr64Stats_f( void ); void SV_PrintStr64Stats_f( void );
#endif
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only ); sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
uint SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name ); uint SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch ); void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );

View File

@ -1017,6 +1017,7 @@ void SV_InitOperatorCommands( void )
Cmd_AddCommand( "redirect", Rcon_Redirect_f, "force enable rcon redirection" ); Cmd_AddCommand( "redirect", Rcon_Redirect_f, "force enable rcon redirection" );
Cmd_AddCommand( "logaddress", SV_SetLogAddress_f, "sets address and port for remote logging host" ); Cmd_AddCommand( "logaddress", SV_SetLogAddress_f, "sets address and port for remote logging host" );
Cmd_AddCommand( "log", SV_ServerLog_f, "enables logging to file" ); Cmd_AddCommand( "log", SV_ServerLog_f, "enables logging to file" );
Cmd_AddCommand( "str64stats", SV_PrintStr64Stats_f, "print engine pool string statistics" );
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL )
{ {
@ -1055,6 +1056,7 @@ void SV_KillOperatorCommands( void )
Cmd_RemoveCommand( "redirect" ); Cmd_RemoveCommand( "redirect" );
Cmd_RemoveCommand( "logaddress" ); Cmd_RemoveCommand( "logaddress" );
Cmd_RemoveCommand( "log" ); Cmd_RemoveCommand( "log" );
Cmd_RemoveCommand( "str64stats" );
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL )
{ {

View File

@ -3282,19 +3282,21 @@ string_t GAME_EXPORT SV_AllocString( const char *szValue )
#endif #endif
} }
#ifdef XASH_64BIT
void SV_PrintStr64Stats_f( void ) void SV_PrintStr64Stats_f( void )
{ {
Msg( "====================\n" ); #ifdef XASH_64BIT
Msg( "64 bit string pool statistics\n" ); Con_Printf( "====================\n" );
Msg( "====================\n" ); Con_Printf( "64 bit string pool statistics\n" );
Msg( "string array size: %lu\n", str64.maxstringarray ); Con_Printf( "====================\n" );
Msg( "total alloc %lu\n", str64.totalalloc ); Con_Printf( "string array size: %lu\n", str64.maxstringarray );
Msg( "maximum array usage: %lu\n", str64.maxalloc ); Con_Printf( "total alloc %lu\n", str64.totalalloc );
Msg( "overflow counter: %lu\n", str64.numoverflows ); Con_Printf( "maximum array usage: %lu\n", str64.maxalloc );
Msg( "dup string counter: %lu\n", str64.numdups ); Con_Printf( "overflow counter: %lu\n", str64.numoverflows );
} Con_Printf( "dup string counter: %lu\n", str64.numdups );
#else
Con_Printf( "Not implemented\n" );
#endif #endif
}
/* /*
============= =============