1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

LibJS: Implement console.time/timeLog/timeEnd() methods

This commit is contained in:
Sam Atkins 2021-12-22 16:40:57 +00:00 committed by Andreas Kling
parent 2f3e24d71e
commit 1fba221b46
5 changed files with 152 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include <AK/HashMap.h>
#include <AK/Noncopyable.h>
#include <AK/Vector.h>
#include <LibCore/ElapsedTimer.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Value.h>
@ -78,17 +79,21 @@ public:
ThrowCompletionOr<Value> group();
ThrowCompletionOr<Value> group_collapsed();
ThrowCompletionOr<Value> group_end();
ThrowCompletionOr<Value> time();
ThrowCompletionOr<Value> time_log();
ThrowCompletionOr<Value> time_end();
void output_debug_message(LogLevel log_level, String output) const;
private:
ThrowCompletionOr<String> value_vector_to_string(Vector<Value>&);
ThrowCompletionOr<String> format_time_since(Core::ElapsedTimer timer);
GlobalObject& m_global_object;
ConsoleClient* m_client { nullptr };
HashMap<String, unsigned> m_counters;
HashMap<String, Core::ElapsedTimer> m_timer_table;
Vector<Group> m_group_stack;
};