MCPcopy Create free account
hub / github.com/facebook/CacheLib / formatTime

Method formatTime

cachelib/cachebench/consistency/ValueHistory.cpp:29–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace cachelib {
28namespace cachebench {
29std::string EventInfo::formatTime() const {
30 // Out format is fixed size. It needs 16 chars with terminating null. For
31 // safety (if someone changes the strftime format) I made it double of it.
32 char buf[32];
33 size_t bufSize{sizeof buf};
34 auto tt = std::chrono::system_clock::to_time_t(tp);
35 struct tm tm_time;
36 ::localtime_r(&tt, &tm_time);
37 ::strftime(buf, bufSize, "%H:%M:%S", &tm_time);
38 auto len = std::strlen(buf);
39 auto micros = std::chrono::duration_cast<std::chrono::microseconds>(
40 tp.time_since_epoch());
41 std::snprintf(buf + len,
42 bufSize - len,
43 ".%06d",
44 static_cast<int>(micros.count() % 1'000'000));
45 return buf;
46}
47
48bool ValueHistory::isWriteEnd(Event e) {
49 switch (e) {

Callers 2

formatMethod · 0.80
TESTFunction · 0.80

Calls 1

countMethod · 0.80

Tested by 1

TESTFunction · 0.64