engine: upgrade benchmark

This commit is contained in:
nillerusr 2022-11-16 13:51:03 +03:00
parent db3062c60b
commit de873d3fc3
5 changed files with 47 additions and 6 deletions

View File

@ -71,11 +71,14 @@ void CBenchmarkResults::StartBenchmark( const CCommand &args )
SetResultsFilename( pszFilename );
// set any necessary settings
host_framerate.SetValue( (float)(1.0f / host_state.interval_per_tick) );
//host_framerate.SetValue( (float)(1.0f / host_state.interval_per_tick) );
// get the current frame and time
m_iStartFrame = host_framecount;
m_flStartTime = realtime;
m_flNextSecondTime = realtime + 1.0f;
m_iNextSecondFrame = host_framecount;
}
//-----------------------------------------------------------------------------
@ -86,7 +89,7 @@ void CBenchmarkResults::StopBenchmark()
m_bIsTestRunning = false;
// reset
host_framerate.SetValue( 0 );
//host_framerate.SetValue( 0 );
// print out some stats
int numticks = host_framecount - m_iStartFrame;
@ -103,12 +106,23 @@ void CBenchmarkResults::StopBenchmark()
kv->SetFloat( "framerate", framerate );
kv->SetInt( "build", build_number() );
CUtlString str;
for( int i = 0; i < m_FPSInfo.Count(); i++ )
{
str += m_FPSInfo[i];
if( i != m_FPSInfo.Count()-1 )
str += ',';
}
kv->SetString( "framerates", str );
// get material system info
GetMaterialSystemConfigForBenchmarkUpload( kv );
// save
kv->SaveToFile( g_pFileSystem, szFilename, "MOD" );
kv->deleteThis();
m_FPSInfo.Purge();
}
//-----------------------------------------------------------------------------
@ -152,6 +166,20 @@ void CBenchmarkResults::Upload()
#endif
}
void CBenchmarkResults::Frame()
{
if( !m_bIsTestRunning )
return;
if( m_flNextSecondTime <= realtime )
{
m_FPSInfo.AddToTail( host_framecount-m_iNextSecondFrame );
m_flNextSecondTime += 1.0f;
m_iNextSecondFrame = host_framecount;
}
}
CON_COMMAND_F( bench_start, "Starts gathering of info. Arguments: filename to write results into", FCVAR_CHEAT )
{
GetBenchResultsMgr()->StartBenchmark( args );

View File

@ -34,13 +34,19 @@ public:
void StopBenchmark();
void SetResultsFilename( const char *pFilename );
void Upload();
void Frame();
private:
bool m_bIsTestRunning;
char m_szFilename[256];
int m_flStartTime;
float m_flStartTime;
int m_iStartFrame;
float m_flNextSecondTime;
int m_iNextSecondFrame;
CUtlVector<int> m_FPSInfo;
};
inline CBenchmarkResults *GetBenchResultsMgr()

View File

@ -72,6 +72,7 @@
#include "cl_rcon.h"
#include "host_state.h"
#include "voice.h"
#include "cbenchmark.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@ -2845,6 +2846,9 @@ void SV_Think( bool bIsSimulating )
bIsSimulating = bIsSimulating && ( sv.IsMultiplayer() || cl.IsActive() );
g_pServerPluginHandler->GameFrame( bIsSimulating );
if( bIsSimulating )
GetBenchResultsMgr()->Frame();
}
//-----------------------------------------------------------------------------
@ -2920,6 +2924,7 @@ void SV_Frame( bool finalTick )
// unlock sting tables to allow changes, helps to find unwanted changes (bebug build only)
networkStringTableContainerServer->Lock( false );
// Run any commands from client and play client Think functions if it is time.
sv.RunFrame(); // read network input etc

View File

@ -6481,6 +6481,7 @@ HRESULT ID3DXMatrixStack::Create()
m_stack.EnsureCapacity( 16 ); // 1KB ish
m_stack.AddToTail();
m_stackTop = 0; // top of stack is at index 0 currently
m_mark = false;
LoadIdentity();

View File

@ -6478,6 +6478,7 @@ HRESULT ID3DXMatrixStack::Create()
m_stack.EnsureCapacity( 16 ); // 1KB ish
m_stack.AddToTail();
m_stackTop = 0; // top of stack is at index 0 currently
m_mark = false;
LoadIdentity();