2017-12-05 20:55:27 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-12-05 20:55:27 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2017-12-05 20:55:27 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2020-05-11 21:39:23 +03:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-05 20:55:27 +03:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents access to the system clock(s).
|
|
|
|
*/
|
|
|
|
class Clock {
|
|
|
|
public:
|
|
|
|
virtual ~Clock() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the real time elapsed since the Epoch.
|
|
|
|
*/
|
2018-02-01 22:09:26 +03:00
|
|
|
virtual timespec getRealtime() const = 0;
|
2017-12-05 20:55:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class UnixClock : public Clock {
|
|
|
|
public:
|
|
|
|
/// CLOCK_REALTIME
|
2018-02-01 22:09:26 +03:00
|
|
|
timespec getRealtime() const override;
|
2020-05-11 21:39:23 +03:00
|
|
|
static float getElapsedTimeInNs(timespec startTime, timespec currTime);
|
2017-12-05 20:55:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|