]> git.cworth.org Git - apitrace/blobdiff - retrace.cpp
Merge branch 'master' into d3dretrace
[apitrace] / retrace.cpp
index fe0694d6a3726faf24b45df321160645a498fc69..1630995cdb440551232c6bdfcd214ea1f61f2abe 100644 (file)
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <iostream>
 
+#include "os_time.hpp"
 #include "trace_dump.hpp"
 #include "retrace.hpp"
 
@@ -38,6 +39,7 @@ trace::Parser parser;
 
 
 int verbosity = 0;
+bool profiling = false;
 
 
 static bool call_dumped = false;
@@ -117,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);
+    }
 }