9 char const*
const kOperationNames[] = {
10 "check",
"close",
"construct",
"destruct",
"flush",
"open",
11 "position",
"prefetch",
"read",
"readActual",
"readAsync",
"readPrefetchToCache",
12 "readViaCache",
"readv",
"resize",
"seek",
"stagein",
"stat",
13 "write",
"writeActual",
"writeViaCache",
"writev"};
16 tbb::concurrent_unordered_map<std::string, int> s_nameToToken;
17 std::atomic<int> s_nextTokenValue{0};
35 return kOperationNames[static_cast<int>(operation)];
39 auto itFound = s_nameToToken.find(iName);
40 if (itFound != s_nameToToken.end()) {
43 int value = s_nextTokenValue++;
45 s_nameToToken.insert(std::make_pair(iName,
value));
51 for (
auto it = s_nameToToken.begin(), itEnd = s_nameToToken.end(); it != itEnd; ++it) {
52 if (it->second == iToken.
value()) {
61 std::ostringstream os;
63 os <<
"stats: class/operation/attempts/successes/amount/time-total/time-min/time-max\n";
64 for (
auto i = s_nameToToken.begin();
i != s_nameToToken.end(); ++
i) {
65 auto const& opStats =
m_stats[
i->second];
66 for (
auto j = opStats.begin();
j != opStats.end(); ++
j,
first =
false)
67 os << (
first ?
"" :
"; ") << (
i->first) <<
'/' << kOperationNames[
j->first] <<
'=' <<
j->second.attempts <<
'/'
68 <<
j->second.successes <<
'/' << (static_cast<double>(
j->second.amount) / 1024 / 1024) <<
"MB/"
69 << (static_cast<double>(
j->second.timeTotal) / 1000 / 1000) <<
"ms/"
70 << (static_cast<double>(
j->second.timeMin) / 1000 / 1000) <<
"ms/"
71 << (static_cast<double>(
j->second.timeMax) / 1000 / 1000) <<
"ms";
77 int const oneM = 1000 * 1000;
78 int const oneMeg = 1024 * 1024;
79 for (
auto i = s_nameToToken.begin();
i != s_nameToToken.end(); ++
i) {
80 auto const& opStats =
m_stats[
i->second];
81 for (
auto j = opStats.begin();
j != opStats.end(); ++
j) {
82 std::ostringstream os;
83 os <<
"Timing-" <<
i->first <<
"-" << kOperationNames[
j->first] <<
"-";
84 summary.insert(std::make_pair(os.str() +
"numOperations",
i2str(
j->second.attempts)));
85 summary.insert(std::make_pair(os.str() +
"numSuccessfulOperations",
i2str(
j->second.successes)));
87 std::make_pair(os.str() +
"totalMegabytes",
d2str(static_cast<double>(
j->second.amount) / oneMeg)));
88 summary.insert(std::make_pair(os.str() +
"totalMsecs",
d2str(static_cast<double>(
j->second.timeTotal) / oneM)));
89 summary.insert(std::make_pair(os.str() +
"minMsecs",
d2str(static_cast<double>(
j->second.timeMin) / oneM)));
90 summary.insert(std::make_pair(os.str() +
"maxMsecs",
d2str(static_cast<double>(
j->second.timeMax) / oneM)));
100 return opstats[static_cast<int>(operation)];
104 : m_counter(
counter), m_start(
std::chrono::high_resolution_clock::
now()) {
110 uint64_t elapsed = elapsed_ns.count();
111 m_counter.successes++;
113 m_counter.vector_count +=
count;
115 m_counter.amount += amount;
119 if (elapsed < m_counter.timeMin || m_counter.successes == 1)
120 m_counter.timeMin = elapsed;
121 if (elapsed > m_counter.timeMax)
122 m_counter.timeMax = elapsed;