43 #define MNE_TRACE() UTILSLIB::MNETracer _mneTracer__LINE__(__FILE__,__func__,__LINE__);
44 #define MNE_TRACER_ENABLE(FILENAME) UTILSLIB::MNETracer::enable(#FILENAME);
45 #define MNE_TRACER_DISABLE UTILSLIB::MNETracer::disable();
46 #define MNE_TRACE_VALUE(NAME, VALUE) UTILSLIB::MNETracer::traceQuantity(NAME, VALUE);
49 #define MNE_TRACER_ENABLE(FILENAME)
50 #define MNE_TRACER_DISABLE
51 #define MNE_TRACE_VALUE()
54 #ifdef MNE_TRACE_MEMORY
55 #define MNE_TRACE_MEMORY_REPORT \
56 std::cout << "Total Memory Allocated : " << 0.000001 * __totalMemAllocated << " MB\n";\
57 std::cout << "Total Memory Deleted : " << 0.000001 * __totalMemDeleted << " MB\n";\
58 std::cout << "Total Memory Diff : " << 0.000001 * (__totalMemAllocated - __totalMemDeleted) << " MB\n";\
60 size_t __totalMemAllocated(0);
61 size_t __totalMemDeleted(0);
62 void *
operator new(
size_t size)
65 __totalMemAllocated += size;
69 void operator delete(
void *memory,
size_t size)
72 __totalMemDeleted += size;
76 #define MNE_TRACE_MEMORY_REPORT
131 MNETracer(
const std::string& file,
const std::string&
function,
int lineNumber);
144 static void enable(
const std::string& jsonFileName);
149 static void enable();
155 static void disable();
161 static void start(
const std::string& jsonFileName);
178 static void traceQuantity(
const std::string& name,
long val);
184 bool printToTerminalIsSet();
190 void setPrintToTerminal(
bool s);
197 static void writeHeader();
203 static void writeFooter();
209 static void writeToFile(
const std::string& str);
215 static void setZeroTime();
221 static long long getTimeNow();
232 void formatFileName();
237 void formatFunctionName();
242 void registerConstructionTime();
247 void registerFinalTime();
252 void registerThreadId();
257 void calculateDuration();
262 void printDurationMiliSec();
267 void writeBeginEvent();
272 void writeEndEvent();
274 static bool ms_bIsEnabled;
275 static std::ofstream ms_OutputFileStream;
276 static bool ms_bIsFirstEvent;
277 static std::mutex ms_outFileMutex;
278 static long long ms_iZeroTime;
280 bool m_bIsInitialized;
281 bool m_bPrintToTerminal;
282 std::string m_sFileName;
283 std::string m_sFunctionName;
285 std::string m_iThreadId;
286 long long m_iBeginTime;
287 long long m_iEndTime;
288 double m_dDurationMilis;
293 #endif //if TRACE defined