Skip to content

Commit

Permalink
Add benchmark mode to commandline options (#5178)
Browse files Browse the repository at this point in the history
Adding `--benchmark` to commandline options to automatically start
benchmark mode, set unlimited FPS, save result and exit.

Signed-off-by: Ettore Chimenti <[email protected]>
Co-authored-by: Ettore Chimenti <[email protected]>
  • Loading branch information
ektor5 and Ettore Chimenti authored Oct 16, 2024
1 parent a1595ca commit 41d6aea
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/config/user_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ namespace UserConfigParams

PARAM_PREFIX bool m_disable_addon_tracks PARAM_DEFAULT( false );

PARAM_PREFIX bool m_benchmark PARAM_DEFAULT( false );

// ---- Networking
PARAM_PREFIX StringToUIntUserConfigParam m_server_bookmarks
PARAM_DEFAULT(StringToUIntUserConfigParam("server-bookmarks",
Expand Down
26 changes: 21 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ void cmdLineHelp()
"laps.\n"
" --profile-time=n Enable automatic driven profile mode for n "
"seconds.\n"
" --benchmark Start Benchmark Mode, save results and exit. \n"
" --unlock-all Permanently unlock all karts and tracks for testing.\n"
" --no-unlock-all Disable unlock-all (i.e. base unlocking on player achievement).\n"
" --xmas=n Toggle Xmas/Christmas mode. n=0 Use current date, n=1, Always enable,\n"
Expand Down Expand Up @@ -1707,6 +1708,14 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
RaceManager::get()->setNumLaps(n);
}
} // --profile-laps

if(CommandLine::has("--benchmark"))
{
Log::verbose("main", "Benchmark mode requested from command-line");
UserConfigParams::m_no_start_screen = true;
UserConfigParams::m_max_fps = 9999;
UserConfigParams::m_benchmark = true;
} // --benchmark

if(CommandLine::has("--unlock-all"))
{
Expand Down Expand Up @@ -2552,11 +2561,18 @@ int main(int argc, char *argv[])
{
if(UserConfigParams::m_no_start_screen)
{
// Quickstart (-N)
// ===============
// all defaults are set in InitTuxkart()
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
if (UserConfigParams::m_benchmark)
{
profiler.startBenchmark();
}
else
{
// Quickstart (-N)
// ===============
// all defaults are set in InitTuxkart()
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
}
}
}
else // profile
Expand Down
12 changes: 11 additions & 1 deletion src/states_screens/race_result_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "utils/profiler.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#include "main_loop.hpp"

#include <algorithm>

Expand Down Expand Up @@ -1269,7 +1270,16 @@ void RaceResultGUI::renderGlobal(float dt)
}
else if (RaceManager::get()->isBenchmarking())
{
displayBenchmarkSummary();
if(!UserConfigParams::m_benchmark)
{
displayBenchmarkSummary();
}
else
{
// Benchmark requested from CLI, write to file and exit
profiler.writeToFile();
main_loop->requestAbort();
}
}
else
{
Expand Down

0 comments on commit 41d6aea

Please sign in to comment.