summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorparadust7 <102263465+paradust7@users.noreply.github.com>2022-05-06 13:17:16 -0700
committerGitHub <noreply@github.com>2022-05-06 21:17:16 +0100
commit87472150bcb83e9cbad2f567ac536de0456ceb70 (patch)
tree027a80a417245989764c45d6923e9c81c7785805 /src/main.cpp
parent45d318a77300b014b13366ee9fa4cfc69e08f360 (diff)
downloadminetest-87472150bcb83e9cbad2f567ac536de0456ceb70.tar.gz
minetest-87472150bcb83e9cbad2f567ac536de0456ceb70.tar.bz2
minetest-87472150bcb83e9cbad2f567ac536de0456ceb70.zip
Add benchmarks for json string serialize/deserialize (#12258)
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 15 insertions, 0 deletions
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,