From 8a53ffb05c214775aab1df17bab818a7f83c7977 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Fri, 25 Dec 2009 23:24:37 -0500 Subject: [PATCH] more Top cleaning --- util/top.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util/top.h b/util/top.h index ad6d8a80617..aaf7c3f5af0 100644 --- a/util/top.h +++ b/util/top.h @@ -29,6 +29,7 @@ namespace mongo { class Top { typedef boost::posix_time::ptime T; typedef boost::posix_time::time_duration D; + typedef boost::tuple< D, int, int, int > UsageData; public: Top() : _read(false), _write(false) { } @@ -128,7 +129,7 @@ namespace mongo { const char *ret = strrchr( ns, '.' ); return ret && ret[ 1 ] == '\0'; } - typedef map< string, boost::tuple< D, int, int, int > > UsageMap; // duration, # reads, # writes, # total calls + typedef map UsageMap; // duration, # reads, # writes, # total calls static T currentTime() { return boost::posix_time::microsec_clock::universal_time(); } @@ -137,12 +138,13 @@ namespace mongo { recordUsageForMap( _nextSnapshot, client, duration ); } void recordUsageForMap( UsageMap &map, const string &client, D duration ) { - map[ client ].get< 0 >() += duration; + UsageData& g = map[client]; + g.get< 0 >() += duration; if ( _read && !_write ) - map[ client ].get< 1 >()++; + g.get< 1 >()++; else if ( !_read && _write ) - map[ client ].get< 2 >()++; - map[ client ].get< 3 >()++; + g.get< 2 >()++; + g.get< 3 >()++; } static void fillParentNamespaces( UsageMap &to, const UsageMap &from ) { for( UsageMap::const_iterator i = from.begin(); i != from.end(); ++i ) { @@ -158,7 +160,7 @@ namespace mongo { } } } - static void inc( boost::tuple< D, int, int, int > &to, const boost::tuple< D, int, int, int > &from ) { + static void inc( UsageData &to, const UsageData &from ) { to.get<0>() += from.get<0>(); to.get<1>() += from.get<1>(); to.get<2>() += from.get<2>();