summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2023-01-01 13:30:09 -0700
committerLinus Groh <mail@linusgroh.de>2023-01-07 14:51:04 +0100
commit82a01bf32f94911de7e3d864b0c22c6cb857bf2b (patch)
tree865b382738f401b27fff907f67a14eef2a951e53 /Userland
parentf7025435b227b9124394799dbb817a39aba986d6 (diff)
downloadserenity-82a01bf32f94911de7e3d864b0c22c6cb857bf2b.zip
LibJS: Use Core::ElapsedTimer in Bytecode::Pass instead of gettimeofday
We have a nice utility for doing exactly what this code is using, so let's use it :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/PassManager.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/PassManager.h b/Userland/Libraries/LibJS/Bytecode/PassManager.h
index c2f457fec5..2be204fae7 100644
--- a/Userland/Libraries/LibJS/Bytecode/PassManager.h
+++ b/Userland/Libraries/LibJS/Bytecode/PassManager.h
@@ -6,10 +6,9 @@
#pragma once
+#include <LibCore/ElapsedTimer.h>
#include <LibJS/Bytecode/BasicBlock.h>
#include <LibJS/Bytecode/Generator.h>
-#include <sys/time.h>
-#include <time.h>
namespace JS::Bytecode {
@@ -28,31 +27,18 @@ public:
virtual void perform(PassPipelineExecutable&) = 0;
void started()
{
- gettimeofday(&m_start_time, nullptr);
+ m_timer.start();
}
void finished()
{
- struct timeval end_time {
- 0, 0
- };
- gettimeofday(&end_time, nullptr);
- time_t interval_s = end_time.tv_sec - m_start_time.tv_sec;
- suseconds_t interval_us = end_time.tv_usec;
- if (interval_us < m_start_time.tv_usec) {
- interval_s -= 1;
- interval_us += 1000000;
- }
- interval_us -= m_start_time.tv_usec;
- m_time_difference = interval_s * 1000000 + interval_us;
+ m_time_difference = m_timer.elapsed_time();
}
- u64 elapsed() const { return m_time_difference; }
+ u64 elapsed() const { return m_time_difference.to_microseconds(); }
protected:
- struct timeval m_start_time {
- 0, 0
- };
- u64 m_time_difference { 0 };
+ Core::ElapsedTimer m_timer;
+ Time m_time_difference {};
};
class PassManager : public Pass {