2017-08-04 03:41:42 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a human-readable string for a time duration.
|
|
|
|
*
|
|
|
|
* Example return values:
|
|
|
|
* 3ns
|
|
|
|
* 10.456ms
|
|
|
|
* 1d23h3500.123s
|
|
|
|
*/
|
|
|
|
std::string durationStr(std::chrono::nanoseconds duration);
|
2017-08-19 00:10:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Comparision operators for comparing two timespec structs.
|
|
|
|
*/
|
|
|
|
bool operator<(const timespec& a, const timespec& b);
|
|
|
|
bool operator<=(const timespec& a, const timespec& b);
|
|
|
|
inline bool operator>=(const timespec& a, const timespec& b) {
|
|
|
|
return !(b < a);
|
|
|
|
}
|
|
|
|
inline bool operator>(const timespec& a, const timespec& b) {
|
|
|
|
return !(b <= a);
|
|
|
|
}
|
|
|
|
inline bool operator==(const timespec& a, const timespec& b) {
|
|
|
|
return (a.tv_sec == b.tv_sec) && (a.tv_nsec == b.tv_nsec);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const timespec& a, const timespec& b) {
|
|
|
|
return !(b == a);
|
|
|
|
}
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|