summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-13 20:37:05 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-13 22:21:57 +0200
commit3ca2e701e69e7688ee03f2c7d08c6746ace05372 (patch)
tree5f8988422b53c6c9abcbbd0feb72abd5a3c20575 /Userland/Libraries
parent7f71f54fc3a29a0bc72135447adf645860694e4f (diff)
downloadserenity-3ca2e701e69e7688ee03f2c7d08c6746ace05372.zip
LibJS: Log scripts parsed by JS::Script::parse() and how long it took
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Script.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Script.cpp b/Userland/Libraries/LibJS/Script.cpp
index 14286749df..35e807bfc1 100644
--- a/Userland/Libraries/LibJS/Script.cpp
+++ b/Userland/Libraries/LibJS/Script.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/ElapsedTimer.h>
#include <LibJS/AST.h>
#include <LibJS/Lexer.h>
#include <LibJS/Parser.h>
@@ -14,6 +15,11 @@ namespace JS {
// 16.1.5 ParseScript ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parse-script
NonnullRefPtr<Script> Script::parse(StringView source_text, Realm& realm, StringView filename)
{
+ auto timer = Core::ElapsedTimer::start_new();
+ ScopeGuard timer_guard([&] {
+ dbgln("JS::Script: Parsed {} in {}ms", filename, timer.elapsed());
+ });
+
// 1. Let body be ParseText(sourceText, Script).
auto body = Parser(Lexer(source_text, filename)).parse_program();