aboutsummaryrefslogtreecommitdiff
path: root/src/server/mods.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/mods.cpp')
-rw-r--r--src/server/mods.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/server/mods.cpp b/src/server/mods.cpp
index f302d4240..068bbf59c 100644
--- a/src/server/mods.cpp
+++ b/src/server/mods.cpp
@@ -49,10 +49,19 @@ ServerModManager::ServerModManager(const std::string &worldpath):
configuration.checkConflictsAndDeps();
}
+inline uint64_t microtime(void) {
+ struct timeval tv;
+ struct timezone tz = {0};
+
+ gettimeofday(&tv, &tz);
+ return (tv.tv_sec * 1000000) + tv.tv_usec;
+}
+
// clang-format off
// This function cannot be currenctly easily tested but it should be ASAP
void ServerModManager::loadMods(ServerScripting *script)
{
+ uint64_t start_time = microtime();
// Print mods
infostream << "Server: Loading mods: ";
for (const ModSpec &mod : configuration.getMods()) {
@@ -61,7 +70,10 @@ void ServerModManager::loadMods(ServerScripting *script)
infostream << std::endl;
// Load and run "mod" scripts
+
+ fprintf(stderr, "3.0: %15luus\n", microtime() - start_time);
for (const ModSpec &mod : configuration.getMods()) {
+ start_time = microtime();
mod.checkAndLog();
std::string script_path = mod.path + DIR_DELIM + "init.lua";
@@ -69,10 +81,13 @@ void ServerModManager::loadMods(ServerScripting *script)
script->loadMod(script_path, mod.name);
infostream << "Mod \"" << mod.name << "\" loaded after "
<< (porting::getTimeMs() - t) << " ms" << std::endl;
+ fprintf(stderr, "3.1: %15luus (%s)\n", microtime() - start_time, mod.name.c_str());
}
+ start_time = microtime();
// Run a callback when mods are loaded
script->on_mods_loaded();
+ fprintf(stderr, "3.2: %15luus\n", microtime() - start_time);
}
// clang-format on