10 char const*
const kOperationNames[] = {
11 "check",
"close",
"construct",
"destruct",
"flush",
"open",
12 "position",
"prefetch",
"read",
"readActual",
"readAsync",
"readPrefetchToCache",
13 "readViaCache",
"readv",
"resize",
"seek",
"stagein",
"stat",
14 "write",
"writeActual",
"writeViaCache",
"writev"};
17 oneapi::tbb::concurrent_unordered_map<std::string, int> s_nameToToken;
18 std::atomic<int> s_nextTokenValue{0};
36 return kOperationNames[
static_cast<int>(operation)];
40 auto itFound = s_nameToToken.find(iName);
41 if (itFound != s_nameToToken.end()) {
44 int value = s_nextTokenValue++;
46 s_nameToToken.insert(std::make_pair(iName,
value));
52 for (
auto it = s_nameToToken.begin(), itEnd = s_nameToToken.end(); it != itEnd; ++it) {
53 if (it->second == iToken.
value()) {
62 std::ostringstream os;
64 os <<
"stats: class/operation/attempts/successes/amount/time-total/time-min/time-max\n";
65 for (
auto i = s_nameToToken.begin();
i != s_nameToToken.end(); ++
i) {
66 auto const& opStats =
m_stats[
i->second];
67 for (
auto j = opStats.begin();
j != opStats.end(); ++
j,
first =
false)
68 os << (
first ?
"" :
"; ") << (
i->first) <<
'/' << kOperationNames[
j->first] <<
'=' <<
j->second.attempts <<
'/' 69 <<
j->second.successes <<
'/' << (static_cast<double>(
j->second.amount) / 1024 / 1024) <<
"MB/" 70 << (static_cast<double>(
j->second.timeTotal) / 1000 / 1000) <<
"ms/" 71 << (static_cast<double>(
j->second.timeMin) / 1000 / 1000) <<
"ms/" 72 << (static_cast<double>(
j->second.timeMax) / 1000 / 1000) <<
"ms";
78 int const oneM = 1000 * 1000;
79 int const oneMeg = 1024 * 1024;
80 for (
auto i = s_nameToToken.begin();
i != s_nameToToken.end(); ++
i) {
81 auto const& opStats =
m_stats[
i->second];
82 for (
auto j = opStats.begin();
j != opStats.end(); ++
j) {
83 std::ostringstream os;
84 os <<
"Timing-" <<
i->first <<
"-" << kOperationNames[
j->first] <<
"-";
85 summary.insert(std::make_pair(os.str() +
"numOperations",
i2str(
j->second.attempts)));
86 summary.insert(std::make_pair(os.str() +
"numSuccessfulOperations",
i2str(
j->second.successes)));
88 std::make_pair(os.str() +
"totalMegabytes",
d2str(static_cast<double>(
j->second.amount) / oneMeg)));
89 summary.insert(std::make_pair(os.str() +
"totalMsecs",
d2str(static_cast<double>(
j->second.timeTotal) / oneM)));
90 summary.insert(std::make_pair(os.str() +
"minMsecs",
d2str(static_cast<double>(
j->second.timeMin) / oneM)));
91 summary.insert(std::make_pair(os.str() +
"maxMsecs",
d2str(static_cast<double>(
j->second.timeMax) / oneM)));
101 return opstats[
static_cast<int>(operation)];
105 : m_counter(
counter), m_start(
std::chrono::high_resolution_clock::
now()) {
111 uint64_t elapsed = elapsed_ns.count();
112 m_counter.successes++;
114 m_counter.vector_count +=
count;
116 m_counter.amount += amount;
120 if (elapsed < m_counter.timeMin || m_counter.successes == 1)
121 m_counter.timeMin = elapsed;
122 if (elapsed > m_counter.timeMax)
123 m_counter.timeMax = elapsed;
static std::string summaryText(bool banner=false)
boost::date_time::subsecond_duration< boost::posix_time::time_duration, 1000000000 > nanoseconds
static StorageClassToken tokenForStorageClassName(std::string const &iName)
oneapi::tbb::concurrent_unordered_map< int, OperationStats > StorageStats
static Counter & counter(StorageClassToken token, Operation operation)
void tick(uint64_t amount=0, int64_t tick=0) const
static void fillSummary(std::map< std::string, std::string > &summary)
static std::string d2str(double d)
static const std::string & nameForToken(StorageClassToken)
static std::string i2str(int i)
std::atomic< uint64_t > attempts
unsigned long long uint64_t
static const StorageStats & summary(void)
static StorageStats m_stats
static char const * operationName(Operation operation)
static void addTo(std::atomic< double > &iAtomic, double iToAdd)
T first(std::pair< T, U > const &p)