21 using namespace folly;
39 static std::chrono::time_point<StubClock>
now() {
40 return std::chrono::time_point<StubClock>(std::chrono::duration<int>(
t));
47 TEST(TestAutoTimer, HandleBasicClosure) {
55 auto timer = makeAutoTimer<decltype(logger), StubClock>(
56 "", std::chrono::duration<double>::zero(),
std::move(logger));
61 timer.logFormat(
"bar {}", 5e-2);
66 TEST(TestAutoTimer, HandleBasic) {
78 TEST(TestAutoTimer, HandleLogOnDestruct) {
92 TEST(TestAutoTimer, HandleRealTimerClosure) {
94 "Third message on destruction",
95 std::chrono::duration<double>::zero(),
99 t.log(
"First message");
100 t.log(
"Second message");
103 TEST(TestAutoTimer, HandleRealTimer) {
105 t.
log(
"First message");
106 t.
log(
"Second message");
109 TEST(TestAutoTimer, HandleMinLogTime) {
115 ASSERT_EQ(std::chrono::duration<double>(2), timer.
log(
"foo"));
119 TEST(TestAutoTimer, MovedObjectDestructionDoesntLog) {
120 const std::vector<std::string> expectedMsgs = {
121 "BEFORE_MOVE",
"AFTER_MOVE",
"END"};
127 auto timer = [&expectedMsgs, &
current] {
130 std::chrono::duration<double>::zero(),
131 [&expectedMsgs, ¤t](
132 StringPiece msg,
const std::chrono::duration<double>&) {
133 EXPECT_EQ(expectedMsgs.at(current), msg);
136 oldTimer.log(
"BEFORE_MOVE");
140 timer.log(
"AFTER_MOVE");
std::chrono::seconds duration
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
DoubleSeconds logFormat(Args &&...args)
—— Concurrent Priority Queue Implementation ——
static std::chrono::time_point< StubClock > now()
static map< string, int > m
auto makeAutoTimer(std::string &&msg="", const std::chrono::duration< double > &minTimeToLog=std::chrono::duration< double >::zero(), Logger &&logger=Logger())
DoubleSeconds log(StringPiece msg="")
void operator()(StringPiece msg, std::chrono::duration< double > sec)
TEST(SequencedExecutor, CPUThreadPoolExecutor)