Mercurial > hg > svcore
comparison base/Debug.h @ 1864:166d7a4c2cd6 startup-timing
Add timings to debug output
author | Chris Cannam |
---|---|
date | Wed, 03 Jun 2020 13:57:37 +0100 |
parents | ad2d3e0a8b7c |
children |
comparison
equal
deleted
inserted
replaced
1859:4c5736a517e0 | 1864:166d7a4c2cd6 |
---|---|
16 #ifndef SV_DEBUG_H | 16 #ifndef SV_DEBUG_H |
17 #define SV_DEBUG_H | 17 #define SV_DEBUG_H |
18 | 18 |
19 #include <QDebug> | 19 #include <QDebug> |
20 #include <QTextStream> | 20 #include <QTextStream> |
21 #include <QElapsedTimer> | |
21 | 22 |
22 #include "RealTime.h" | 23 #include "RealTime.h" |
23 | 24 |
24 #include <string> | 25 #include <string> |
25 #include <iostream> | 26 #include <iostream> |
44 template <typename T> | 45 template <typename T> |
45 inline SVDebug &operator<<(const T &t) { | 46 inline SVDebug &operator<<(const T &t) { |
46 if (m_silenced) return *this; | 47 if (m_silenced) return *this; |
47 if (m_ok) { | 48 if (m_ok) { |
48 if (m_eol) { | 49 if (m_eol) { |
49 m_stream << m_prefix << " "; | 50 m_stream << m_prefix << "/" << m_timer.elapsed() << ": "; |
50 } | 51 } |
51 m_stream << t; | 52 m_stream << t; |
52 m_eol = false; | 53 m_eol = false; |
53 } | 54 } |
54 return *this; | 55 return *this; |
66 private: | 67 private: |
67 std::fstream m_stream; | 68 std::fstream m_stream; |
68 char *m_prefix; | 69 char *m_prefix; |
69 bool m_ok; | 70 bool m_ok; |
70 bool m_eol; | 71 bool m_eol; |
72 QElapsedTimer m_timer; | |
71 static bool m_silenced; | 73 static bool m_silenced; |
72 }; | 74 }; |
73 | 75 |
74 class SVCerr { | 76 class SVCerr { |
75 public: | 77 public: |