mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
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 :^)
This commit is contained in:
parent
f7025435b2
commit
82a01bf32f
1 changed files with 6 additions and 20 deletions
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibCore/ElapsedTimer.h>
|
||||||
#include <LibJS/Bytecode/BasicBlock.h>
|
#include <LibJS/Bytecode/BasicBlock.h>
|
||||||
#include <LibJS/Bytecode/Generator.h>
|
#include <LibJS/Bytecode/Generator.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
namespace JS::Bytecode {
|
namespace JS::Bytecode {
|
||||||
|
|
||||||
|
@ -28,31 +27,18 @@ public:
|
||||||
virtual void perform(PassPipelineExecutable&) = 0;
|
virtual void perform(PassPipelineExecutable&) = 0;
|
||||||
void started()
|
void started()
|
||||||
{
|
{
|
||||||
gettimeofday(&m_start_time, nullptr);
|
m_timer.start();
|
||||||
}
|
}
|
||||||
void finished()
|
void finished()
|
||||||
{
|
{
|
||||||
struct timeval end_time {
|
m_time_difference = m_timer.elapsed_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 elapsed() const { return m_time_difference; }
|
u64 elapsed() const { return m_time_difference.to_microseconds(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct timeval m_start_time {
|
Core::ElapsedTimer m_timer;
|
||||||
0, 0
|
Time m_time_difference {};
|
||||||
};
|
|
||||||
u64 m_time_difference { 0 };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PassManager : public Pass {
|
class PassManager : public Pass {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue