mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Add support for profiling from scripts
This commit is contained in:
parent
bda52c33e6
commit
c24e254257
3 changed files with 20 additions and 2 deletions
|
@ -1284,8 +1284,8 @@ void ScriptEngine::timerFired() {
|
|||
|
||||
// call the associated JS function, if it exists
|
||||
if (timerData.function.isValid()) {
|
||||
//PROFILE_RANGE(script, __FUNCTION__);
|
||||
PROFILE_RANGE(script, timerData.function.toString().toStdString().c_str());
|
||||
PROFILE_RANGE(script, __FUNCTION__);
|
||||
// PROFILE_RANGE(script, timerData.function.toString().toStdString().c_str());
|
||||
auto preTimer = p_high_resolution_clock::now();
|
||||
callWithEnvironment(timerData.definingEntityIdentifier, timerData.definingSandboxURL, timerData.function, timerData.function, QScriptValueList());
|
||||
auto postTimer = p_high_resolution_clock::now();
|
||||
|
@ -1396,6 +1396,19 @@ void ScriptEngine::print(const QString& message) {
|
|||
emit printedMessage(message, getFilename());
|
||||
}
|
||||
|
||||
|
||||
void ScriptEngine::beginProfileRange(const QString& label) const {
|
||||
if (trace_script().isDebugEnabled()) {
|
||||
tracing::traceEvent(trace_script(), label.toStdString().c_str(), tracing::DurationBegin);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEngine::endProfileRange(const QString& label) const {
|
||||
if (trace_script().isDebugEnabled()) {
|
||||
tracing::traceEvent(trace_script(), label.toStdString().c_str(), tracing::DurationEnd);
|
||||
}
|
||||
}
|
||||
|
||||
// Script.require.resolve -- like resolvePath, but performs more validation and throws exceptions on invalid module identifiers (for consistency with Node.js)
|
||||
QString ScriptEngine::_requireResolve(const QString& moduleId, const QString& relativeTo) {
|
||||
if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "Vec3.h"
|
||||
#include "ConsoleScriptingInterface.h"
|
||||
#include "SettingHandle.h"
|
||||
#include "Profile.h"
|
||||
|
||||
class QScriptEngineDebugger;
|
||||
|
||||
|
@ -182,6 +183,8 @@ public:
|
|||
Q_INVOKABLE void print(const QString& message);
|
||||
Q_INVOKABLE QUrl resolvePath(const QString& path) const;
|
||||
Q_INVOKABLE QUrl resourcesPath() const;
|
||||
Q_INVOKABLE void beginProfileRange(const QString& label) const;
|
||||
Q_INVOKABLE void endProfileRange(const QString& label) const;
|
||||
|
||||
// Entity Script Related methods
|
||||
Q_INVOKABLE bool isEntityScriptRunning(const EntityItemID& entityID) {
|
||||
|
|
|
@ -1173,6 +1173,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.update = function(deltaTime, timestamp) {
|
||||
Script.beginProfileRange("handControllerGrab:MyController:update")
|
||||
this.updateSmoothedTrigger();
|
||||
this.maybeScaleMyAvatar();
|
||||
|
||||
|
@ -1209,6 +1210,7 @@ function MyController(hand) {
|
|||
} else {
|
||||
print("WARNING: could not find state " + this.state + " in state machine");
|
||||
}
|
||||
Script.endProfileRange("handControllerGrab:MyController:update")
|
||||
};
|
||||
|
||||
this.callEntityMethodOnGrabbed = function(entityMethodName) {
|
||||
|
|
Loading…
Reference in a new issue