Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 4 files). Show all
Unified · Split
| @@ -64,6 +64,8 @@ · 63 unmodified lines | ||
| 64 | 64 | #include "ScriptEngines.h" |
| 65 | 65 | #include "TabletScriptingInterface.h" |
| 66 | 66 | |
| 67 | +#include <Profile.h> | |
| 68 | + | |
| 67 | 69 | #include "MIDIEvent.h" |
| 68 | 70 | |
| 69 | 71 | static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3"; |
| @@ -927,7 +929,10 @@ void ScriptEngine::run() { · 857 unmodified lines | ||
| 927 | 929 | bool processedEvents = false; |
| 928 | 930 | while (!_isFinished && clock::now() < sleepUntil) { |
| 929 | 931 | |
| 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 | + } | |
| 931 | 936 | processedEvents = true; |
| 932 | 937 | |
| 933 | 938 | // If after processing events, we're past due, exit asap |
| @@ -942,6 +947,8 @@ void ScriptEngine::run() { · 8 unmodified lines | ||
| 942 | 947 | std::this_thread::sleep_until(smallSleepUntil); |
| 943 | 948 | } |
| 944 | 949 | |
| 950 | + PROFILE_RANGE(script, "ScriptMainLoop"); | |
| 951 | + | |
| 945 | 952 | #ifdef SCRIPT_DELAY_DEBUG |
| 946 | 953 | { |
| 947 | 954 | auto actuallySleptUntil = clock::now(); |
| @@ -965,6 +972,7 @@ void ScriptEngine::run() { · 17 unmodified lines | ||
| 965 | 972 | |
| 966 | 973 | // Only call this if we didn't processEvents as part of waiting for next frame |
| 967 | 974 | if (!processedEvents) { |
| 975 | + PROFILE_RANGE(script, "processEvents"); | |
| 968 | 976 | QCoreApplication::processEvents(); |
| 969 | 977 | } |
| 970 | 978 | |
| @@ -989,7 +997,10 @@ void ScriptEngine::run() { · 18 unmodified lines | ||
| 989 | 997 | float deltaTime = (float) (now - _lastUpdate) / (float) USECS_PER_SECOND; |
| 990 | 998 | if (!_isFinished) { |
| 991 | 999 | auto preUpdate = clock::now(); |
| 992 | − emit update(deltaTime); | |
| 1000 | + { | |
| 1001 | + PROFILE_RANGE(script, "ScriptUpdate"); | |
| 1002 | + emit update(deltaTime); | |
| 1003 | + } | |
| 993 | 1004 | auto postUpdate = clock::now(); |
| 994 | 1005 | auto elapsed = (postUpdate - preUpdate); |
| 995 | 1006 | totalUpdates += std::chrono::duration_cast<std::chrono::microseconds>(elapsed); |