File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change 6
6
7
7
#pragma once
8
8
9
+ #include < AK/Time.h>
9
10
#include < LibCore/DirIterator.h>
10
11
#include < fcntl.h>
11
12
#include < sys/stat.h>
@@ -15,10 +16,8 @@ namespace Test {
15
16
16
17
inline double get_time_in_ms ()
17
18
{
18
- struct timeval tv1;
19
- auto return_code = gettimeofday (&tv1, nullptr );
20
- VERIFY (return_code >= 0 );
21
- return static_cast <double >(tv1.tv_sec ) * 1000.0 + static_cast <double >(tv1.tv_usec ) / 1000.0 ;
19
+ auto now = UnixDateTime::now ();
20
+ return static_cast <double >(now.milliseconds_since_epoch ());
22
21
}
23
22
24
23
template <typename Callback>
Original file line number Diff line number Diff line change 6
6
*/
7
7
8
8
#include < AK/Function.h>
9
+ #include < AK/Time.h>
9
10
#include < LibCore/ArgsParser.h>
10
11
#include < LibTest/Macros.h>
11
12
#include < LibTest/TestResult.h>
@@ -22,21 +23,15 @@ class TestElapsedTimer {
22
23
public:
23
24
TestElapsedTimer () { restart (); }
24
25
25
- void restart () { gettimeofday (& m_started, nullptr ); }
26
+ void restart () { m_started = UnixDateTime::now ( ); }
26
27
27
28
u64 elapsed_milliseconds ()
28
29
{
29
- struct timeval now = {};
30
- gettimeofday (&now, nullptr );
31
-
32
- struct timeval delta = {};
33
- timersub (&now, &m_started, &delta);
34
-
35
- return delta.tv_sec * 1000 + delta.tv_usec / 1000 ;
30
+ return (UnixDateTime::now () - m_started).to_milliseconds ();
36
31
}
37
32
38
33
private:
39
- struct timeval m_started = {} ;
34
+ UnixDateTime m_started;
40
35
};
41
36
42
37
// Declared in Macros.h
You can’t perform that action at this time.
0 commit comments