mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Merge #3337
3337: Add benchmark command for pts r=Jupeyy a=def- More platform-independent than using libframetime: https://github.com/clbr/libframetime Uses the same output format. Made some commands use rest instead of string so you don't need quotes for the parameter. ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
8b8eed3f0d
|
@ -359,6 +359,8 @@ CClient::CClient() :
|
|||
m_GenerateTimeoutSeed = true;
|
||||
|
||||
m_FrameTimeAvg = 0.0001f;
|
||||
m_BenchmarkFile = 0;
|
||||
m_BenchmarkStopTime = 0;
|
||||
}
|
||||
|
||||
// ----- send functions -----
|
||||
|
@ -3258,6 +3260,19 @@ void CClient::Run()
|
|||
m_RenderFrameTimeHigh = m_RenderFrameTime;
|
||||
m_FpsGraph.Add(1.0f / m_RenderFrameTime, 1, 1, 1);
|
||||
|
||||
if(m_BenchmarkFile)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "Frametime %d us\n", (int)(m_RenderFrameTime * 1000000));
|
||||
io_write(m_BenchmarkFile, aBuf, strlen(aBuf));
|
||||
if(time_get() > m_BenchmarkStopTime)
|
||||
{
|
||||
io_close(m_BenchmarkFile);
|
||||
m_BenchmarkFile = 0;
|
||||
Quit();
|
||||
}
|
||||
}
|
||||
|
||||
m_FrameTimeAvg = m_FrameTimeAvg * 0.9f + m_RenderFrameTime * 0.1f;
|
||||
|
||||
// keep the overflow time - it's used to make sure the gfx refreshrate is reached
|
||||
|
@ -3912,6 +3927,21 @@ void CClient::Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->DemoRecorder_AddDemoMarker(RECORDER_REPLAYS);
|
||||
}
|
||||
|
||||
void CClient::Con_BenchmarkQuit(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CClient *pSelf = (CClient *)pUserData;
|
||||
int Seconds = pResult->GetInteger(0);
|
||||
const char *pFilename = pResult->GetString(1);
|
||||
pSelf->BenchmarkQuit(Seconds, pFilename);
|
||||
}
|
||||
|
||||
void CClient::BenchmarkQuit(int Seconds, const char *pFilename)
|
||||
{
|
||||
char aBuf[MAX_PATH_LENGTH];
|
||||
m_BenchmarkFile = Storage()->OpenFile(pFilename, IOFLAG_WRITE, IStorage::TYPE_ABSOLUTE, aBuf, sizeof(aBuf));
|
||||
m_BenchmarkStopTime = time_get() + time_freq() * Seconds;
|
||||
}
|
||||
|
||||
void CClient::ServerBrowserUpdate()
|
||||
{
|
||||
m_ResortServerBrowser = true;
|
||||
|
@ -4097,11 +4127,11 @@ void CClient::RegisterCommands()
|
|||
// register server dummy commands for tab completion
|
||||
m_pConsole->Register("kick", "i[id] ?r[reason]", CFGFLAG_SERVER, 0, 0, "Kick player with specified id for any reason");
|
||||
m_pConsole->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes for any reason");
|
||||
m_pConsole->Register("unban", "s[ip]", CFGFLAG_SERVER, 0, 0, "Unban ip");
|
||||
m_pConsole->Register("unban", "r[ip]", CFGFLAG_SERVER, 0, 0, "Unban ip");
|
||||
m_pConsole->Register("bans", "", CFGFLAG_SERVER, 0, 0, "Show banlist");
|
||||
m_pConsole->Register("status", "?r[name]", CFGFLAG_SERVER, 0, 0, "List players containing name or all players");
|
||||
m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, 0, 0, "Shut down");
|
||||
m_pConsole->Register("record", "s[file]", CFGFLAG_SERVER, 0, 0, "Record to a file");
|
||||
m_pConsole->Register("record", "r[file]", CFGFLAG_SERVER, 0, 0, "Record to a file");
|
||||
m_pConsole->Register("stoprecord", "", CFGFLAG_SERVER, 0, 0, "Stop recording");
|
||||
m_pConsole->Register("reload", "", CFGFLAG_SERVER, 0, 0, "Reload the map");
|
||||
|
||||
|
@ -4111,7 +4141,7 @@ void CClient::RegisterCommands()
|
|||
m_pConsole->Register("quit", "", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Quit, this, "Quit Teeworlds");
|
||||
m_pConsole->Register("exit", "", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Quit, this, "Quit Teeworlds");
|
||||
m_pConsole->Register("minimize", "", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Minimize, this, "Minimize Teeworlds");
|
||||
m_pConsole->Register("connect", "s[host|ip]", CFGFLAG_CLIENT, Con_Connect, this, "Connect to the specified host/ip");
|
||||
m_pConsole->Register("connect", "r[host|ip]", CFGFLAG_CLIENT, Con_Connect, this, "Connect to the specified host/ip");
|
||||
m_pConsole->Register("disconnect", "", CFGFLAG_CLIENT, Con_Disconnect, this, "Disconnect from the server");
|
||||
m_pConsole->Register("ping", "", CFGFLAG_CLIENT, Con_Ping, this, "Ping the current server");
|
||||
m_pConsole->Register("screenshot", "", CFGFLAG_CLIENT, Con_Screenshot, this, "Take a screenshot");
|
||||
|
@ -4122,20 +4152,21 @@ void CClient::RegisterCommands()
|
|||
#endif
|
||||
|
||||
m_pConsole->Register("rcon", "r[rcon-command]", CFGFLAG_CLIENT, Con_Rcon, this, "Send specified command to rcon");
|
||||
m_pConsole->Register("rcon_auth", "s[password]", CFGFLAG_CLIENT, Con_RconAuth, this, "Authenticate to rcon");
|
||||
m_pConsole->Register("rcon_auth", "r[password]", CFGFLAG_CLIENT, Con_RconAuth, this, "Authenticate to rcon");
|
||||
m_pConsole->Register("rcon_login", "s[username] r[password]", CFGFLAG_CLIENT, Con_RconLogin, this, "Authenticate to rcon with a username");
|
||||
m_pConsole->Register("play", "r[file]", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Play, this, "Play the file specified");
|
||||
m_pConsole->Register("record", "?s[file]", CFGFLAG_CLIENT, Con_Record, this, "Record to the file");
|
||||
m_pConsole->Register("record", "?r[file]", CFGFLAG_CLIENT, Con_Record, this, "Record to the file");
|
||||
m_pConsole->Register("stoprecord", "", CFGFLAG_CLIENT, Con_StopRecord, this, "Stop recording");
|
||||
m_pConsole->Register("add_demomarker", "", CFGFLAG_CLIENT, Con_AddDemoMarker, this, "Add demo timeline marker");
|
||||
m_pConsole->Register("add_favorite", "s[host|ip]", CFGFLAG_CLIENT, Con_AddFavorite, this, "Add a server as a favorite");
|
||||
m_pConsole->Register("remove_favorite", "s[host|ip]", CFGFLAG_CLIENT, Con_RemoveFavorite, this, "Remove a server from favorites");
|
||||
m_pConsole->Register("add_favorite", "r[host|ip]", CFGFLAG_CLIENT, Con_AddFavorite, this, "Add a server as a favorite");
|
||||
m_pConsole->Register("remove_favorite", "r[host|ip]", CFGFLAG_CLIENT, Con_RemoveFavorite, this, "Remove a server from favorites");
|
||||
m_pConsole->Register("demo_slice_start", "", CFGFLAG_CLIENT, Con_DemoSliceBegin, this, "");
|
||||
m_pConsole->Register("demo_slice_end", "", CFGFLAG_CLIENT, Con_DemoSliceEnd, this, "");
|
||||
m_pConsole->Register("demo_play", "", CFGFLAG_CLIENT, Con_DemoPlay, this, "Play demo");
|
||||
m_pConsole->Register("demo_speed", "i[speed]", CFGFLAG_CLIENT, Con_DemoSpeed, this, "Set demo speed");
|
||||
|
||||
m_pConsole->Register("save_replay", "?i[length]", CFGFLAG_CLIENT, Con_SaveReplay, this, "Save a replay of the last defined amount of seconds");
|
||||
m_pConsole->Register("benchmark_quit", "i[seconds] r[file]", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_BenchmarkQuit, this, "Benchmark frame times for number of seconds to file, then quit");
|
||||
|
||||
m_pConsole->Chain("cl_timeout_seed", ConchainTimeoutSeed, this);
|
||||
m_pConsole->Chain("cl_replays", ConchainReplays, this);
|
||||
|
|
|
@ -264,6 +264,9 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
CFifo m_Fifo;
|
||||
#endif
|
||||
|
||||
IOHANDLE m_BenchmarkFile;
|
||||
int64 m_BenchmarkStopTime;
|
||||
|
||||
public:
|
||||
IEngine *Engine() { return m_pEngine; }
|
||||
IEngineGraphics *Graphics() { return m_pGraphics; }
|
||||
|
@ -415,6 +418,7 @@ public:
|
|||
static void Con_Record(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_StopRecord(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_BenchmarkQuit(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConchainServerBrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainFullscreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainWindowBordered(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
@ -461,6 +465,7 @@ public:
|
|||
void ToggleWindowVSync();
|
||||
void LoadFont();
|
||||
void Notify(const char *pTitle, const char *pMessage);
|
||||
void BenchmarkQuit(int Seconds, const char *pFilename);
|
||||
|
||||
// DDRace
|
||||
|
||||
|
|
Loading…
Reference in a new issue