#include <string.h>
#include <assert.h>
#include <sstream>
+#include "os_time.hpp"
namespace trace {
Profiler::Profiler()
}
if (cpuTimes) {
- cpuStart -= baseCpuTime;
+ double cpuTimeScale = 1.0E9 / os::timeFrequency;
+ cpuStart = (cpuStart - baseCpuTime) * cpuTimeScale;
+ cpuDuration = cpuDuration * cpuTimeScale;
} else {
cpuStart = 0;
cpuDuration = 0;
if (baseCpuTime == 0) {
baseCpuTime = cpuStart;
}
+
+ lastFrame.no = no;
+ lastFrame.gpuStart = gpuStart;
+ lastFrame.cpuStart = cpuStart;
if (gpuTimes) {
- lastFrame.gpuStart = gpuStart - baseGpuTime;
+ gpuStart = gpuStart - baseGpuTime;
} else {
- lastFrame.gpuStart = 0;
+ gpuStart = 0;
}
if (cpuTimes) {
- lastFrame.cpuStart = cpuStart - baseCpuTime;
+ double cpuTimeScale = 1.0E9 / os::timeFrequency;
+ cpuStart = (cpuStart - baseCpuTime) * cpuTimeScale;
} else {
- lastFrame.cpuStart = 0;
+ cpuStart = 0;
}
- lastFrame.no = no;
-
std::cout << "frame_begin"
- << " " << lastFrame.no
- << " " << lastFrame.gpuStart
- << " " << lastFrame.cpuStart
+ << " " << no
+ << " " << gpuStart
+ << " " << cpuStart
<< std::endl;
}
uint64_t gpuDuration, cpuDuration;
if (gpuTimes) {
- gpuEnd -= baseGpuTime;
gpuDuration = gpuEnd - lastFrame.gpuStart;
+ gpuEnd = gpuEnd - baseGpuTime;
} else {
gpuEnd = 0;
gpuDuration = 0;
}
if (cpuTimes) {
- cpuEnd -= baseCpuTime;
- cpuDuration = cpuEnd - lastFrame.cpuStart;
+ double cpuTimeScale = 1.0E9 / os::timeFrequency;
+ cpuDuration = (cpuEnd - lastFrame.cpuStart) * cpuTimeScale;
+ cpuEnd = (cpuEnd - baseCpuTime) * cpuTimeScale;
} else {
cpuEnd = 0;
cpuDuration = 0;
static GLuint64
getCpuTimestamp() {
if (retrace::profilingCpuTimes) {
- return os::getTime() * (1.0E9 / os::timeFrequency);
+ return os::getTime();
} else {
return 0;
}
endProfile(trace::Call &call) {
if (retrace::profilingCpuTimes) {
CallQuery& query = callQueries.back();
- query.duration = (os::getTime() - query.start) * (1.0E9 / os::timeFrequency);
+ query.duration = os::getTime() - query.start;
}
if (retrace::profilingGpuTimes && supportsElapsed) {