From d56513b72237abaeea6e024ff939fa6b2aac8e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 16 Feb 2020 21:19:01 +0100 Subject: [PATCH] Add code to measure search function speed --- config/jsdoc/api/template/static/scripts/main.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index d91411db42..1df350cafa 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -85,11 +85,21 @@ $(function () { const searchInput = $('#search').get(0); // Skip searches when typing fast. let key; + let start; + const brandNode = document.querySelector('.brand'); function queueSearch() { if (!key) { + start = Date.now(); key = setTimeout(function () { - doSearch(searchInput.value); key = undefined; + + const searchTerm = searchInput.value; + doSearch(searchTerm); + + const time = Date.now() - start + brandNode.innerHTML = time + ' ms'; + console.log(searchTerm + ':', time, 'ms'); + start = undefined; }, 0); } }