This commit is contained in:
samcake 2017-06-23 14:18:56 -07:00
parent b7b520a6e8
commit c0e8b6c8bc
3 changed files with 18 additions and 9 deletions

View file

@ -1283,7 +1283,6 @@ 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());
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,15 +1395,11 @@ void ScriptEngine::print(const QString& message) {
void ScriptEngine::beginProfileRange(const QString& label) const {
if (trace_script().isDebugEnabled()) {
tracing::traceEvent(trace_script(), label.toStdString().c_str(), tracing::DurationBegin);
}
PROFILE_SYNC_BEGIN(script, label.toStdString().c_str(), label.toStdString().c_str());
}
void ScriptEngine::endProfileRange(const QString& label) const {
if (trace_script().isDebugEnabled()) {
tracing::traceEvent(trace_script(), label.toStdString().c_str(), tracing::DurationEnd);
}
PROFILE_SYNC_END(script, label.toStdString().c_str(), label.toStdString().c_str());
}
// Script.require.resolve -- like resolvePath, but performs more validation and throws exceptions on invalid module identifiers (for consistency with Node.js)

View file

@ -46,6 +46,20 @@ private:
const QLoggingCategory& _category;
};
inline void syncBegin(const QLoggingCategory& category, const QString& name, const QString& id, const QVariantMap& args = QVariantMap(), const QVariantMap& extra = QVariantMap()) {
if (category.isDebugEnabled()) {
tracing::traceEvent(category, name, tracing::DurationBegin, id, args, extra);
}
}
inline void syncEnd(const QLoggingCategory& category, const QString& name, const QString& id, const QVariantMap& args = QVariantMap(), const QVariantMap& extra = QVariantMap()) {
if (category.isDebugEnabled()) {
tracing::traceEvent(category, name, tracing::DurationEnd, id, args, extra);
}
}
inline void asyncBegin(const QLoggingCategory& category, const QString& name, const QString& id, const QVariantMap& args = QVariantMap(), const QVariantMap& extra = QVariantMap()) {
if (category.isDebugEnabled()) {
tracing::traceEvent(category, name, tracing::AsyncNestableStart, id, args, extra);
@ -80,6 +94,8 @@ inline void metadata(const QString& metadataType, const QVariantMap& args) {
#define PROFILE_RANGE_EX(category, name, argbColor, payload, ...) Duration profileRangeThis(trace_##category(), name, argbColor, (uint64_t)payload, ##__VA_ARGS__);
#define PROFILE_RANGE_BEGIN(category, rangeId, name, argbColor) rangeId = Duration::beginRange(trace_##category(), name, argbColor)
#define PROFILE_RANGE_END(category, rangeId) Duration::endRange(trace_##category(), rangeId)
#define PROFILE_SYNC_BEGIN(category, name, id, ...) syncBegin(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_SYNC_END(category, name, id, ...) syncEnd(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_ASYNC_BEGIN(category, name, id, ...) asyncBegin(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_ASYNC_END(category, name, id, ...) asyncEnd(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_COUNTER_IF_CHANGED(category, name, type, value) { static type lastValue = 0; type newValue = value; if (newValue != lastValue) { counter(trace_##category(), name, { { name, newValue }}); lastValue = newValue; } }

View file

@ -1173,7 +1173,6 @@ function MyController(hand) {
};
this.update = function(deltaTime, timestamp) {
Script.beginProfileRange("handControllerGrab:MyController:update")
this.updateSmoothedTrigger();
this.maybeScaleMyAvatar();
@ -1210,7 +1209,6 @@ function MyController(hand) {
} else {
print("WARNING: could not find state " + this.state + " in state machine");
}
Script.endProfileRange("handControllerGrab:MyController:update")
};
this.callEntityMethodOnGrabbed = function(entityMethodName) {