mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#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);
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
} // namespace eden
|
|
} // namespace facebook
|