mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-04 01:18:36 +02:00
Add profiling to edit.js fof the entity list
This commit is contained in:
parent
133ac0662a
commit
f6ac755bae
2 changed files with 109 additions and 75 deletions
|
@ -23,6 +23,18 @@ const DELETE = 46; // Key code for the delete key.
|
||||||
const KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
const KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
||||||
const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities.
|
const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities.
|
||||||
|
|
||||||
|
var profileIndent = '';
|
||||||
|
PROFILE = function(name, fn, args) {
|
||||||
|
EventBridge.emitWebEvent("PROFILE-Web " + profileIndent + "(" + name + ") Begin");
|
||||||
|
var previousIndent = profileIndent;
|
||||||
|
profileIndent += ' ';
|
||||||
|
var before = Date.now();
|
||||||
|
fn.apply(this, args);
|
||||||
|
var delta = Date.now() - before;
|
||||||
|
profileIndent = previousIndent;
|
||||||
|
EventBridge.emitWebEvent("PROFILE-Web " + profileIndent + "(" + name + ") End " + delta + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
debugPrint = function (message) {
|
debugPrint = function (message) {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
};
|
};
|
||||||
|
@ -363,6 +375,7 @@ function loaded() {
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
}
|
}
|
||||||
} else if (data.type === "update" && data.selectedIDs !== undefined) {
|
} else if (data.type === "update" && data.selectedIDs !== undefined) {
|
||||||
|
PROFILE("update", function() {
|
||||||
var newEntities = data.entities;
|
var newEntities = data.entities;
|
||||||
if (newEntities && newEntities.length == 0) {
|
if (newEntities && newEntities.length == 0) {
|
||||||
elNoEntitiesMessage.style.display = "block";
|
elNoEntitiesMessage.style.display = "block";
|
||||||
|
@ -384,6 +397,7 @@ function loaded() {
|
||||||
scheduleRefreshEntityList();
|
scheduleRefreshEntityList();
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} else if (data.type === "removeEntities" && data.deletedIDs !== undefined && data.selectedIDs !== undefined) {
|
} else if (data.type === "removeEntities" && data.deletedIDs !== undefined && data.selectedIDs !== undefined) {
|
||||||
removeEntities(data.deletedIDs);
|
removeEntities(data.deletedIDs);
|
||||||
updateSelectedEntities(data.selectedIDs);
|
updateSelectedEntities(data.selectedIDs);
|
||||||
|
|
|
@ -11,6 +11,18 @@
|
||||||
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
|
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
|
||||||
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */
|
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */
|
||||||
|
|
||||||
|
var profileIndent = '';
|
||||||
|
PROFILE = function(name, fn, args) {
|
||||||
|
console.log("PROFILE-Script " + profileIndent + "(" + name + ") Begin");
|
||||||
|
var previousIndent = profileIndent;
|
||||||
|
profileIndent += ' ';
|
||||||
|
var before = Date.now();
|
||||||
|
fn.apply(this, args);
|
||||||
|
var delta = Date.now() - before;
|
||||||
|
profileIndent = previousIndent;
|
||||||
|
console.log("PROFILE-Script " + profileIndent + "(" + name + ") End " + delta + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
EntityListTool = function(shouldUseEditTabletApp) {
|
EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -66,11 +78,16 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
that.setVisible(false);
|
that.setVisible(false);
|
||||||
|
|
||||||
function emitJSONScriptEvent(data) {
|
function emitJSONScriptEvent(data) {
|
||||||
var dataString = JSON.stringify(data);
|
var dataString;
|
||||||
|
PROFILE("Script-JSON.stringify", function() {
|
||||||
|
dataString = JSON.stringify(data);
|
||||||
|
});
|
||||||
|
PROFILE("Script-emitScriptEvent", function() {
|
||||||
webView.emitScriptEvent(dataString);
|
webView.emitScriptEvent(dataString);
|
||||||
if (entityListWindow.window) {
|
if (entityListWindow.window) {
|
||||||
entityListWindow.window.emitScriptEvent(dataString);
|
entityListWindow.window.emitScriptEvent(dataString);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
that.toggleVisible = function() {
|
that.toggleVisible = function() {
|
||||||
|
@ -116,6 +133,7 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
that.sendUpdate = function() {
|
that.sendUpdate = function() {
|
||||||
|
PROFILE('Script-sendUpdate', function() {
|
||||||
var entities = [];
|
var entities = [];
|
||||||
|
|
||||||
var ids;
|
var ids;
|
||||||
|
@ -170,6 +188,7 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
entities: entities,
|
entities: entities,
|
||||||
selectedIDs: selectedIDs,
|
selectedIDs: selectedIDs,
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function onFileSaveChanged(filename) {
|
function onFileSaveChanged(filename) {
|
||||||
|
@ -186,7 +205,8 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
print("entityList.js: Error parsing JSON: " + e.name + " data " + data);
|
console.log(data);
|
||||||
|
//print("entityList.js: Error parsing JSON: " + e.name + " data " + data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue