History

Add tracing to ScriptEngine and EntitiesScriptingInterface

Ryan Huffman committed 9 years ago

Commit 55df6f81 parent ce9f8be4 files · +66 −2Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+13−2
@@ -64,6 +64,8 @@ · 63 unmodified lines
6464 #include "ScriptEngines.h"
6565 #include "TabletScriptingInterface.h"
6666
67+#include <Profile.h>
68+
6769 #include "MIDIEvent.h"
6870
6971 static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3";
@@ -927,7 +929,10 @@ void ScriptEngine::run() { · 857 unmodified lines
927929 bool processedEvents = false;
928930 while (!_isFinished && clock::now() < sleepUntil) {
929931
930− QCoreApplication::processEvents(); // before we sleep again, give events a chance to process
932+ {
933+ PROFILE_RANGE(script, "processEvents-sleep");
934+ QCoreApplication::processEvents(); // before we sleep again, give events a chance to process
935+ }
931936 processedEvents = true;
932937
933938 // If after processing events, we're past due, exit asap
@@ -942,6 +947,8 @@ void ScriptEngine::run() { · 8 unmodified lines
942947 std::this_thread::sleep_until(smallSleepUntil);
943948 }
944949
950+ PROFILE_RANGE(script, "ScriptMainLoop");
951+
945952 #ifdef SCRIPT_DELAY_DEBUG
946953 {
947954 auto actuallySleptUntil = clock::now();
@@ -965,6 +972,7 @@ void ScriptEngine::run() { · 17 unmodified lines
965972
966973 // Only call this if we didn't processEvents as part of waiting for next frame
967974 if (!processedEvents) {
975+ PROFILE_RANGE(script, "processEvents");
968976 QCoreApplication::processEvents();
969977 }
970978
@@ -989,7 +997,10 @@ void ScriptEngine::run() { · 18 unmodified lines
989997 float deltaTime = (float) (now - _lastUpdate) / (float) USECS_PER_SECOND;
990998 if (!_isFinished) {
991999 auto preUpdate = clock::now();
992− emit update(deltaTime);
1000+ {
1001+ PROFILE_RANGE(script, "ScriptUpdate");
1002+ emit update(deltaTime);
1003+ }
9931004 auto postUpdate = clock::now();
9941005 auto elapsed = (postUpdate - preUpdate);
9951006 totalUpdates += std::chrono::duration_cast<std::chrono::microseconds>(elapsed);