]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/profiler.h
Move get_schematic and read_schematic to l_mapgen.cpp
[dragonfireclient.git] / src / profiler.h
index 271ad70c1f1947c0b03dfd575b7ce656a1cb592f..5816f05ca66652960034708e4bc60c58fcdcb0ef 100644 (file)
@@ -20,13 +20,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef PROFILER_HEADER
 #define PROFILER_HEADER
 
-#include "irrlichttypes_bloated.h"
+#include "irrlichttypes.h"
 #include <string>
-#include <jmutex.h>
-#include <jmutexautolock.h>
 #include <map>
+
+#include "jthread/jmutex.h"
+#include "jthread/jmutexautolock.h"
 #include "util/timetaker.h"
 #include "util/numeric.h" // paging()
+#include "debug.h" // assert()
+
+#define MAX_PROFILER_TEXT_ROWS 20
 
 /*
        Time profiler
@@ -37,7 +41,6 @@ class Profiler
 public:
        Profiler()
        {
-               m_mutex.Init();
        }
 
        void add(const std::string &name, float value)
@@ -73,7 +76,7 @@ class Profiler
                        else{
                                /* No add shall have been used */
                                assert(n->second != -2);
-                               n->second = (std::max)(n->second, 0) + 1;
+                               n->second = MYMAX(n->second, 0) + 1;
                        }
                }
                {
@@ -164,6 +167,13 @@ class Profiler
                m_graphvalues.clear();
        }
 
+       void remove(const std::string& name)
+       {
+               JMutexAutoLock lock(m_mutex);
+               m_avgcounts.erase(name);
+               m_data.erase(name);
+       }
+
 private:
        JMutex m_mutex;
        std::map<std::string, float> m_data;