From 87472150bcb83e9cbad2f567ac536de0456ceb70 Mon Sep 17 00:00:00 2001 From: paradust7 <102263465+paradust7@users.noreply.github.com> Date: Fri, 6 May 2022 13:17:16 -0700 Subject: Add benchmarks for json string serialize/deserialize (#12258) Co-authored-by: sfan5 --- src/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index ddd725134..ebd1f740e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes.h" // must be included before anything irrlicht, see comment in the file #include "irrlicht.h" // createDevice #include "irrlichttypes_extrabloated.h" +#include "benchmark/benchmark.h" #include "chat_interface.h" #include "debug.h" #include "unittest/test.h" @@ -212,7 +213,19 @@ int main(int argc, char *argv[]) return 1; #endif } + + // Run benchmarks + if (cmd_args.getFlag("run-benchmarks")) { +#if BUILD_BENCHMARKS + return run_benchmarks(); +#else + errorstream << "Benchmark support is not enabled in this binary. " + << "If you want to enable it, compile project with BUILD_BENCHMARKS=1 flag." + << std::endl; + return 1; #endif + } +#endif // __ANDROID__ GameStartData game_params; #ifdef SERVER @@ -277,6 +290,8 @@ static void set_allowed_options(OptionList *allowed_options) _("Set network port (UDP)")))); allowed_options->insert(std::make_pair("run-unittests", ValueSpec(VALUETYPE_FLAG, _("Run the unit tests and exit")))); + allowed_options->insert(std::make_pair("run-benchmarks", ValueSpec(VALUETYPE_FLAG, + _("Run the benchmarks and exit")))); allowed_options->insert(std::make_pair("map-dir", ValueSpec(VALUETYPE_STRING, _("Same as --world (deprecated)")))); allowed_options->insert(std::make_pair("world", ValueSpec(VALUETYPE_STRING, -- cgit v1.2.3