summaryrefslogtreecommitdiffstats
path: root/src/core/jobs/task.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire350@gmail.com>2016-02-26 19:29:38 +0100
committerPaul Lemire <paul.lemire@kdab.com>2016-03-04 19:12:43 +0000
commit27d42a9894cdf31af5bf7c82343da9ea4ef3b64c (patch)
treed90064f8a377574989bf6099a5248f705b788d66 /src/core/jobs/task.cpp
parent52859382c900614a3a88eb3d7aa5af60d2d4a103 (diff)
Qt3D job run stats
Add a way to write to a trace.qt3d file stats about the frame jobs Then use the qt3dprofiler tool to visualize the trace file This is enabled by defining QT3D_JOBS_RUN_STATS at compile time Change-Id: I4d2faaf5189cd91ecc88b7ca0ca3e3e1f2f60498 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/jobs/task.cpp')
-rw-r--r--src/core/jobs/task.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/core/jobs/task.cpp b/src/core/jobs/task.cpp
index cf44cbe24..544fddb5d 100644
--- a/src/core/jobs/task.cpp
+++ b/src/core/jobs/task.cpp
@@ -42,7 +42,7 @@
#include "qthreadpooler_p.h"
#include <QMutexLocker>
-
+#include <QElapsedTimer>
#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -67,8 +67,23 @@ AspectTaskRunnable::~AspectTaskRunnable()
void AspectTaskRunnable::run()
{
- if (m_job)
+ if (m_job) {
+#ifdef QT3D_JOBS_RUN_STATS
+ QAspectJobPrivate *jobD = QAspectJobPrivate::get(m_job.data());
+ if (m_pooler) {
+ jobD->m_stats.startTime = QThreadPooler::m_jobsStatTimer.nsecsElapsed();
+ jobD->m_stats.threadId = reinterpret_cast<quint64>(QThread::currentThreadId());
+ }
+#endif
m_job->run();
+#ifdef QT3D_JOBS_RUN_STATS
+ if (m_pooler) {
+ jobD->m_stats.endTime = QThreadPooler::m_jobsStatTimer.nsecsElapsed();
+ // Add current job's stats to log output
+ QThreadPooler::addJobLogStatsEntry(jobD->m_stats);
+ }
+#endif
+ }
// We could have an append sub task or something in here
// So that a job can post sub jobs ?