From: gregorycu Date: Mon, 2 Nov 2015 03:17:44 +0000 (+1100) Subject: Speed up saving of profiling data by 27x X-Git-Tag: 0.4.14~542 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5c3546e459ede7fbdfc22b340ed6b2af5073ec5b;p=oweals%2Fminetest.git Speed up saving of profiling data by 27x On Windows Release x64 bit build this changes: ProfilerGraph::put 1.68% -> 0.061% ProfilerGraph::draw 12% -> 17.% So yes, there is a tradeoff between saving profiling data (executed always) and drawing the profiler graph (executed very rarely). But usually you don't have the profiler graph open. --- diff --git a/src/game.cpp b/src/game.cpp index df5ab701a..d74c1fa1d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -489,7 +489,7 @@ private: color(color) {} }; - std::vector m_log; + std::deque m_log; public: u32 m_log_max_size; @@ -512,7 +512,7 @@ public: { std::map m_meta; - for (std::vector::const_iterator k = m_log.begin(); + for (std::deque::const_iterator k = m_log.begin(); k != m_log.end(); ++k) { const Piece &piece = *k; @@ -600,7 +600,7 @@ public: float lastscaledvalue = 0.0; bool lastscaledvalue_exists = false; - for (std::vector::const_iterator j = m_log.begin(); + for (std::deque::const_iterator j = m_log.begin(); j != m_log.end(); ++j) { const Piece &piece = *j; float value = 0;