QmlProfiler: send v8 profiling started signal
authorChristiaan Janssen <christiaan.janssen@nokia.com>
Mon, 27 Feb 2012 12:01:03 +0000 (13:01 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 27 Feb 2012 14:26:26 +0000 (15:26 +0100)
Change-Id: Ie26bd47c9b79a7f524b9c5bc59146be1ea93761d
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
src/declarative/debugger/qv8profilerservice.cpp
src/declarative/debugger/qv8profilerservice_p.h
tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp

index 5ae2d01..7a8a350 100644 (file)
@@ -187,6 +187,13 @@ void QV8ProfilerService::startProfiling(const QString &title)
     v8::CpuProfiler::StartProfiling(v8title);
 
     d->m_ongoing.append(title);
+
+    // indicate profiling started
+    QByteArray data;
+    QDataStream ds(&data, QIODevice::WriteOnly);
+    ds << (int)QV8ProfilerService::V8Started;
+
+    sendMessage(data);
 }
 
 void QV8ProfilerService::stopProfiling(const QString &title)
@@ -205,6 +212,13 @@ void QV8ProfilerService::stopProfiling(const QString &title)
         // can happen at start
         const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot();
         d->printProfileTree(rootNode);
+    } else {
+        // indicate completion, even without data
+        QByteArray data;
+        QDataStream ds(&data, QIODevice::WriteOnly);
+        ds << (int)QV8ProfilerService::V8Complete;
+
+        sendMessage(data);
     }
 }
 
index 706907a..3762845 100644 (file)
@@ -85,6 +85,7 @@ public:
         V8Complete,
         V8SnapshotChunk,
         V8SnapshotComplete,
+        V8Started,
 
         V8MaximumMessage
     };
index 92b893a..165783f 100644 (file)
@@ -91,6 +91,7 @@ public:
     QList<QByteArray> snapshotMessages;
 
 signals:
+    void started();
     void complete();
     void snapshot();
 
@@ -158,6 +159,9 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message)
     case QV8ProfilerService::V8SnapshotComplete:
         emit snapshot();
         break;
+    case QV8ProfilerService::V8Started:
+        emit started();
+        break;
     default:
         QString failMessage = QString("Unknown message type: %1").arg(messageType);
         QFAIL(qPrintable(failMessage));
@@ -208,6 +212,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
     QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
 
     m_client->startProfiling("");
+    QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
+             "No start signal received in time.");
     m_client->stopProfiling("");
     QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
              "No trace received in time.");
@@ -225,6 +231,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
         QFAIL(qPrintable(failMsg));
     }
     m_client->startProfiling("");
+    QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
+             "No start signal received in time.");
     m_client->stopProfiling("");
     QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
              "No trace received in time.");
@@ -236,6 +244,8 @@ void tst_QV8ProfilerService::nonBlockingConnect()
     QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
 
     m_client->startProfiling("");
+    QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
+             "No start signal received in time.");
     m_client->stopProfiling("");
     QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
              "No trace received in time.");
@@ -257,6 +267,8 @@ void tst_QV8ProfilerService::profileOnExit()
     QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
 
     m_client->startProfiling("");
+    QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
+             "No start signal received in time.");
 
     QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
              "No trace received in time.");
@@ -270,6 +282,8 @@ void tst_QV8ProfilerService::console()
 
     m_client->stopProfiling("");
 
+    QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
+             "No start signal received in time.");
     QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
              "No trace received in time.");
     QVERIFY(!m_client->traceMessages.isEmpty());