Browse Source

LibWeb: Log classic script start, finish, and duration

When waiting for a page to load, it's nice to see which scripts run,
and how long they take to finish.
Andreas Kling 3 years ago
parent
commit
f6ad7dfc0b
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp

+ 4 - 0
Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp

@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  * SPDX-License-Identifier: BSD-2-Clause
  */
  */
 
 
+#include <LibCore/ElapsedTimer.h>
 #include <LibJS/Interpreter.h>
 #include <LibJS/Interpreter.h>
 #include <LibWeb/HTML/Scripting/ClassicScript.h>
 #include <LibWeb/HTML/Scripting/ClassicScript.h>
 
 
@@ -51,13 +52,16 @@ NonnullRefPtr<ClassicScript> ClassicScript::create(String filename, StringView s
 // https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
 // https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
 JS::Value ClassicScript::run(RethrowErrors rethrow_errors)
 JS::Value ClassicScript::run(RethrowErrors rethrow_errors)
 {
 {
+    dbgln("ClassicScript: Running script {}", filename());
     (void)rethrow_errors;
     (void)rethrow_errors;
 
 
+    auto timer = Core::ElapsedTimer::start_new();
     auto interpreter = JS::Interpreter::create_with_existing_realm(m_script_record->realm());
     auto interpreter = JS::Interpreter::create_with_existing_realm(m_script_record->realm());
     interpreter->run(interpreter->global_object(), m_script_record->parse_node());
     interpreter->run(interpreter->global_object(), m_script_record->parse_node());
     auto& vm = interpreter->vm();
     auto& vm = interpreter->vm();
     if (vm.exception())
     if (vm.exception())
         vm.clear_exception();
         vm.clear_exception();
+    dbgln("ClassicScript: Finished running script {}, Duration: {}ms", filename(), timer.elapsed());
     return vm.last_value();
     return vm.last_value();
 }
 }