diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2020-04-27 08:31:37 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2020-04-29 07:48:08 +0200 |
commit | 56bababcdfce097a4e08cc3d1de8d798e7999ce7 (patch) | |
tree | aef707d6abdcd86bc1520c668f7e2ee4533a638e /src/map.cpp | |
parent | a36c9c3e930608386b983ea76158793fe9d622f6 (diff) | |
download | minetest-56bababcdfce097a4e08cc3d1de8d798e7999ce7.tar.gz minetest-56bababcdfce097a4e08cc3d1de8d798e7999ce7.tar.bz2 minetest-56bababcdfce097a4e08cc3d1de8d798e7999ce7.zip |
Add MetricsBackend with prometheus counter support
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/map.cpp b/src/map.cpp index 12e122124..5f1b984a4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -144,7 +144,7 @@ bool Map::isNodeUnderground(v3s16 p) { v3s16 blockpos = getNodeBlockPos(p); MapBlock *block = getBlockNoCreateNoEx(blockpos); - return block && block->getIsUnderground(); + return block && block->getIsUnderground(); } bool Map::isValidPosition(v3s16 p) @@ -1187,7 +1187,7 @@ bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes) ServerMap */ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef, - EmergeManager *emerge): + EmergeManager *emerge, MetricsBackend *mb): Map(dout_server, gamedef), settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"), m_emerge(emerge) @@ -1221,6 +1221,8 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef, m_savedir = savedir; m_map_saving_enabled = false; + m_save_time_counter = mb->addCounter("minetest_core_map_save_time", "Map save time (in nanoseconds)"); + try { // If directory exists, check contents and load if possible if (fs::PathExists(m_savedir)) { @@ -1777,6 +1779,8 @@ void ServerMap::save(ModifiedState save_level) return; } + u64 start_time = porting::getTimeNs(); + if(save_level == MOD_STATE_CLEAN) infostream<<"ServerMap: Saving whole map, this can take time." <<std::endl; @@ -1835,6 +1839,9 @@ void ServerMap::save(ModifiedState save_level) infostream<<"Blocks modified by: "<<std::endl; modprofiler.print(infostream); } + + auto end_time = porting::getTimeNs(); + m_save_time_counter->increment(end_time - start_time); } void ServerMap::listAllLoadableBlocks(std::vector<v3s16> &dst) |