mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 14:16:50 +00:00
engine: upgrade benchmark
This commit is contained in:
parent
db3062c60b
commit
de873d3fc3
@ -71,11 +71,14 @@ void CBenchmarkResults::StartBenchmark( const CCommand &args )
|
|||||||
SetResultsFilename( pszFilename );
|
SetResultsFilename( pszFilename );
|
||||||
|
|
||||||
// set any necessary settings
|
// 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
|
// get the current frame and time
|
||||||
m_iStartFrame = host_framecount;
|
m_iStartFrame = host_framecount;
|
||||||
m_flStartTime = realtime;
|
m_flStartTime = realtime;
|
||||||
|
|
||||||
|
m_flNextSecondTime = realtime + 1.0f;
|
||||||
|
m_iNextSecondFrame = host_framecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -86,7 +89,7 @@ void CBenchmarkResults::StopBenchmark()
|
|||||||
m_bIsTestRunning = false;
|
m_bIsTestRunning = false;
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
host_framerate.SetValue( 0 );
|
//host_framerate.SetValue( 0 );
|
||||||
|
|
||||||
// print out some stats
|
// print out some stats
|
||||||
int numticks = host_framecount - m_iStartFrame;
|
int numticks = host_framecount - m_iStartFrame;
|
||||||
@ -103,12 +106,23 @@ void CBenchmarkResults::StopBenchmark()
|
|||||||
kv->SetFloat( "framerate", framerate );
|
kv->SetFloat( "framerate", framerate );
|
||||||
kv->SetInt( "build", build_number() );
|
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
|
// get material system info
|
||||||
GetMaterialSystemConfigForBenchmarkUpload( kv );
|
GetMaterialSystemConfigForBenchmarkUpload( kv );
|
||||||
|
|
||||||
// save
|
// save
|
||||||
kv->SaveToFile( g_pFileSystem, szFilename, "MOD" );
|
kv->SaveToFile( g_pFileSystem, szFilename, "MOD" );
|
||||||
kv->deleteThis();
|
kv->deleteThis();
|
||||||
|
|
||||||
|
m_FPSInfo.Purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -152,6 +166,20 @@ void CBenchmarkResults::Upload()
|
|||||||
#endif
|
#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 )
|
CON_COMMAND_F( bench_start, "Starts gathering of info. Arguments: filename to write results into", FCVAR_CHEAT )
|
||||||
{
|
{
|
||||||
GetBenchResultsMgr()->StartBenchmark( args );
|
GetBenchResultsMgr()->StartBenchmark( args );
|
||||||
|
@ -34,13 +34,19 @@ public:
|
|||||||
void StopBenchmark();
|
void StopBenchmark();
|
||||||
void SetResultsFilename( const char *pFilename );
|
void SetResultsFilename( const char *pFilename );
|
||||||
void Upload();
|
void Upload();
|
||||||
|
void Frame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bIsTestRunning;
|
bool m_bIsTestRunning;
|
||||||
char m_szFilename[256];
|
char m_szFilename[256];
|
||||||
|
|
||||||
int m_flStartTime;
|
float m_flStartTime;
|
||||||
int m_iStartFrame;
|
int m_iStartFrame;
|
||||||
|
|
||||||
|
float m_flNextSecondTime;
|
||||||
|
int m_iNextSecondFrame;
|
||||||
|
|
||||||
|
CUtlVector<int> m_FPSInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline CBenchmarkResults *GetBenchResultsMgr()
|
inline CBenchmarkResults *GetBenchResultsMgr()
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
#include "cl_rcon.h"
|
#include "cl_rcon.h"
|
||||||
#include "host_state.h"
|
#include "host_state.h"
|
||||||
#include "voice.h"
|
#include "voice.h"
|
||||||
|
#include "cbenchmark.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -2845,6 +2846,9 @@ void SV_Think( bool bIsSimulating )
|
|||||||
bIsSimulating = bIsSimulating && ( sv.IsMultiplayer() || cl.IsActive() );
|
bIsSimulating = bIsSimulating && ( sv.IsMultiplayer() || cl.IsActive() );
|
||||||
|
|
||||||
g_pServerPluginHandler->GameFrame( bIsSimulating );
|
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)
|
// unlock sting tables to allow changes, helps to find unwanted changes (bebug build only)
|
||||||
networkStringTableContainerServer->Lock( false );
|
networkStringTableContainerServer->Lock( false );
|
||||||
|
|
||||||
|
|
||||||
// Run any commands from client and play client Think functions if it is time.
|
// Run any commands from client and play client Think functions if it is time.
|
||||||
sv.RunFrame(); // read network input etc
|
sv.RunFrame(); // read network input etc
|
||||||
|
|
||||||
|
@ -6481,6 +6481,7 @@ HRESULT ID3DXMatrixStack::Create()
|
|||||||
m_stack.EnsureCapacity( 16 ); // 1KB ish
|
m_stack.EnsureCapacity( 16 ); // 1KB ish
|
||||||
m_stack.AddToTail();
|
m_stack.AddToTail();
|
||||||
m_stackTop = 0; // top of stack is at index 0 currently
|
m_stackTop = 0; // top of stack is at index 0 currently
|
||||||
|
m_mark = false;
|
||||||
|
|
||||||
LoadIdentity();
|
LoadIdentity();
|
||||||
|
|
||||||
|
@ -6478,6 +6478,7 @@ HRESULT ID3DXMatrixStack::Create()
|
|||||||
m_stack.EnsureCapacity( 16 ); // 1KB ish
|
m_stack.EnsureCapacity( 16 ); // 1KB ish
|
||||||
m_stack.AddToTail();
|
m_stack.AddToTail();
|
||||||
m_stackTop = 0; // top of stack is at index 0 currently
|
m_stackTop = 0; // top of stack is at index 0 currently
|
||||||
|
m_mark = false;
|
||||||
|
|
||||||
LoadIdentity();
|
LoadIdentity();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user