diff --git a/public/javascripts/dialogs/jump_to_note.js b/public/javascripts/dialogs/jump_to_note.js index e8695bfd3..9066ad616 100644 --- a/public/javascripts/dialogs/jump_to_note.js +++ b/public/javascripts/dialogs/jump_to_note.js @@ -16,7 +16,7 @@ const jumpToNote = (function() { }); await autoCompleteEl.autocomplete({ - source: noteTree.getAutocompleteItems(), + source: await stopWatch("building autocomplete", noteTree.getAutocompleteItems), minLength: 0 }); } @@ -26,11 +26,6 @@ const jumpToNote = (function() { return link.getNodePathFromLabel(val); } - function getSelectedNoteId() { - const notePath = getSelectedNotePath(); - return treeUtils.getNoteIdFromNotePath(notePath); - } - function goToNote() { const notePath = getSelectedNotePath(); diff --git a/public/javascripts/utils.js b/public/javascripts/utils.js index 1b390d130..130d8394f 100644 --- a/public/javascripts/utils.js +++ b/public/javascripts/utils.js @@ -97,4 +97,16 @@ function isRootNode(node) { function escapeHtml(str) { return $('
').text(str).html(); +} + +async function stopWatch(what, func) { + const start = new Date(); + + const ret = await func(); + + const tookMs = new Date().getTime() - start.getTime(); + + console.log(`${what} took ${tookMs}ms`); + + return ret; } \ No newline at end of file diff --git a/services/utils.js b/services/utils.js index 44d40b686..9dd608b7d 100644 --- a/services/utils.js +++ b/services/utils.js @@ -102,11 +102,13 @@ function assertArguments() { async function stopWatch(what, func) { const start = new Date(); - await func(); + const ret = await func(); const tookMs = new Date().getTime() - start.getTime(); console.log(`${what} took ${tookMs}ms`); + + return ret; } module.exports = {