9 char const *
const kOperationNames[] = {
21 "readPrefetchToCache",
35 tbb::concurrent_unordered_map<std::string, int> s_nameToToken;
36 std::atomic<int> s_nextTokenValue{0};
54 return kOperationNames[
static_cast<int>(operation)];
58 auto itFound = s_nameToToken.find(iName);
59 if( itFound != s_nameToToken.end()) {
62 int value = s_nextTokenValue++;
64 s_nameToToken.insert(std::make_pair(iName, value));
70 for(
auto it = s_nameToToken.begin(), itEnd = s_nameToToken.end(); it != itEnd; ++it) {
71 if (it->second == iToken.
value()) {
82 std::ostringstream os;
84 os <<
"stats: class/operation/attempts/successes/amount/time-total/time-min/time-max\n";
85 for (
auto i = s_nameToToken.begin ();
i != s_nameToToken.end(); ++
i) {
86 auto const& opStats = m_stats[
i->second];
87 for (
auto j = opStats.begin (); j != opStats.end (); ++j, first =
false)
88 os << (first ?
"" :
"; ")
90 << kOperationNames[j->first] <<
'=' 91 << j->second.attempts <<
'/' 92 << j->second.successes <<
'/' 93 << (static_cast<double>(j->second.amount) / 1024 / 1024) <<
"MB/" 94 << (static_cast<double>(j->second.timeTotal) / 1000 / 1000) <<
"ms/" 95 << (static_cast<double>(j->second.timeMin) / 1000 / 1000) <<
"ms/" 96 << (static_cast<double>(j->second.timeMax) / 1000 / 1000) <<
"ms";
103 int const oneM = 1000 * 1000;
104 int const oneMeg = 1024 * 1024;
105 for (
auto i = s_nameToToken.begin ();
i != s_nameToToken.end(); ++
i) {
106 auto const& opStats = m_stats[
i->second];
107 for (
auto j = opStats.begin(); j != opStats.end(); ++j) {
108 std::ostringstream os;
109 os <<
"Timing-" <<
i->first <<
"-" << kOperationNames[j->first] <<
"-";
110 summary.insert(std::make_pair(os.str() +
"numOperations",
i2str(j->second.attempts)));
111 summary.insert(std::make_pair(os.str() +
"numSuccessfulOperations",
i2str(j->second.successes)));
112 summary.insert(std::make_pair(os.str() +
"totalMegabytes",
d2str(static_cast<double>(j->second.amount) / oneMeg)));
113 summary.insert(std::make_pair(os.str() +
"totalMsecs",
d2str(static_cast<double>(j->second.timeTotal) / oneM)));
114 summary.insert(std::make_pair(os.str() +
"minMsecs",
d2str(static_cast<double>(j->second.timeMin) / oneM)));
115 summary.insert(std::make_pair(os.str() +
"maxMsecs",
d2str(static_cast<double>(j->second.timeMax) / oneM)));
126 auto &opstats = m_stats [token.
value()];
128 return opstats[
static_cast<int>(operation)];
132 : m_counter (counter),
133 m_start (
std::chrono::high_resolution_clock::
now())
142 uint64_t elapsed = elapsed_ns.count();
static StorageStats m_stats
static void fillSummary(std::map< std::string, std::string > &summary)
static char const * operationName(Operation operation)
std::atomic< double > timeMax
static const StorageStats & summary(void)
std::atomic< uint64_t > attempts
std::atomic< int64_t > vector_square
std::atomic< int64_t > vector_count
static std::string d2str(double d)
tbb::concurrent_unordered_map< int, OperationStats > StorageStats
std::atomic< double > timeMin
std::chrono::time_point< std::chrono::high_resolution_clock > m_start
static StorageClassToken tokenForStorageClassName(std::string const &iName)
std::atomic< uint64_t > successes
static void addTo(std::atomic< double > &iAtomic, double iToAdd)
static const std::string & nameForToken(StorageClassToken)
std::atomic< double > amount_square
static std::string i2str(int i)
std::atomic< uint64_t > amount
static Counter & counter(StorageClassToken token, Operation operation)
unsigned long long uint64_t
void tick(uint64_t amount=0, int64_t tick=0) const
static std::string summaryText(bool banner=false)
std::atomic< double > timeTotal
boost::date_time::subsecond_duration< boost::posix_time::time_duration, 1000000000 > nanoseconds