]> git.cworth.org Git - apitrace/blobdiff - retrace.cpp
Move tracers to wrappers subdirectory.
[apitrace] / retrace.cpp
index 795d039a11ad464252d4643f6fb466fdfd093085..1630995cdb440551232c6bdfcd214ea1f61f2abe 100644 (file)
 #include <string.h>
 #include <iostream>
 
+#include "os_time.hpp"
+#include "trace_dump.hpp"
 #include "retrace.hpp"
 
 
 namespace retrace {
 
 
+trace::Parser parser;
+
+
 int verbosity = 0;
+bool profiling = false;
 
 
 static bool call_dumped = false;
@@ -113,7 +119,20 @@ void Retracer::retrace(trace::Call &call) {
     assert(callback);
     assert(callbacks[id] == callback);
 
-    callback(call);
+    if (retrace::profiling) {
+        long long startTime = os::getTime();
+        callback(call);
+        long long stopTime = os::getTime();
+        float timeInterval = (stopTime - startTime) * (1.0E6 / os::timeFrequency);
+
+        std::cout
+            << call.no << " "
+            << "[" << timeInterval << " usec] "
+        ;
+        trace::dump(call, std::cout, trace::DUMP_FLAG_NO_CALL_NO | trace::DUMP_FLAG_NO_COLOR);
+    } else {
+        callback(call);
+    }
 }