Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark mode to command-line options #5178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 20 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,13 @@ 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_benchmark = true;
} // --benchmark

if(CommandLine::has("--unlock-all"))
{
Expand Down Expand Up @@ -2552,11 +2560,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
Loading