MCPcopy Create free account
hub / github.com/apple/foundationdb / writeToLog

Method writeToLog

flow/Histogram.cpp:91–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 "percentage", "count", "none" };
90
91void Histogram::writeToLog(double elapsed) {
92 bool active = false;
93 for (uint32_t i = 0; i < 32; i++) {
94 if (buckets[i]) {
95 active = true;
96 break;
97 }
98 }
99 if (!active) {
100 return;
101 }
102
103 TraceEvent e(SevInfo, "Histogram");
104 e.detail("Group", group).detail("Op", op).detail("Unit", UnitToStringMapper[(size_t)unit]);
105 if (elapsed > 0)
106 e.detail("Elapsed", elapsed);
107 int totalCount = 0;
108 for (uint32_t i = 0; i < 32; i++) {
109 uint64_t value = uint64_t(1) << (i + 1);
110
111 if (buckets[i]) {
112 totalCount += buckets[i];
113 switch (unit) {
114 case Unit::microseconds:
115 e.detail(format("LessThan%u.%03u", int(value / 1000), int(value % 1000)), buckets[i]);
116 break;
117 case Unit::bytes:
118 case Unit::bytes_per_second:
119 e.detail(format("LessThan%" PRIu64, value), buckets[i]);
120 break;
121 case Unit::percentageLinear:
122 e.detail(format("LessThan%f", (i + 1) * 0.04), buckets[i]);
123 break;
124 case Unit::countLinear:
125 value = uint64_t((i + 1) * ((upperBound - lowerBound) / 31.0));
126 e.detail(format("LessThan%" PRIu64, value), buckets[i]);
127 break;
128 case Unit::MAXHISTOGRAMUNIT:
129 e.detail(format("Default%u", i), buckets[i]);
130 break;
131 default:
132 ASSERT(false);
133 }
134 }
135 }
136 e.detail("TotalCount", totalCount);
137 clear();
138}
139
140std::string Histogram::drawHistogram() {
141

Callers 3

logReportMethod · 0.80
logHistogramsMethod · 0.80

Calls 3

detailMethod · 0.80
formatFunction · 0.70
clearFunction · 0.50

Tested by

no test coverage detected