summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsys.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-07-11 10:57:14 -0400
committerNat Goodspeed <nat@lindenlab.com>2011-07-11 10:57:14 -0400
commit607f60d6f6ddf18e69b5106bbb6ef31b72ba78f2 (patch)
treeefe568a4b1226caee2566c6e114a023258e02a7a /indra/llcommon/llsys.cpp
parent774306bc25b4b737d318bdd28ab0b078dc60db74 (diff)
CHOP-753: Add timestamp to LLMemoryInfo's LLSD stats block.
For postprocessing these stats, we'll want the time at which they were captured. We'll want the current framerate too, but handle that at a higher level.
Diffstat (limited to 'indra/llcommon/llsys.cpp')
-rw-r--r--indra/llcommon/llsys.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index b3ab5008fb..74a9a68dc8 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -51,6 +51,9 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/range.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_float.hpp>
using namespace llsd;
@@ -649,7 +652,24 @@ public:
mStats(LLSD::emptyArray())
{}
- void add(const LLSD::String& name, LLSD::Integer value)
+ // Store every integer type as LLSD::Integer.
+ template <class T>
+ void add(const LLSD::String& name, const T& value,
+ typename boost::enable_if<boost::is_integral<T> >::type* = 0)
+ {
+ mStats.append(LLSDArray(name)(LLSD::Integer(value)));
+ }
+
+ // Store every floating-point type as LLSD::Real.
+ template <class T>
+ void add(const LLSD::String& name, const T& value,
+ typename boost::enable_if<boost::is_float<T> >::type* = 0)
+ {
+ mStats.append(LLSDArray(name)(LLSD::Real(value)));
+ }
+
+ // Hope that LLSD::Date values are sufficiently unambiguous.
+ void add(const LLSD::String& name, const LLSD::Date& value)
{
mStats.append(LLSDArray(name)(value));
}
@@ -847,9 +867,16 @@ void LLMemoryInfo::stream(std::ostream& s) const
// Now stream stats
BOOST_FOREACH(LLSD pair, inArray(mStatsArray))
{
- s << pfx << std::setw(key_width+1) << (pair[0].asString() + ':')
- << ' '
- << std::setw(12) << pair[1].asInteger() << std::endl;
+ s << pfx << std::setw(key_width+1) << (pair[0].asString() + ':') << ' ';
+ if (pair[1].isInteger())
+ s << std::setw(12) << pair[1].asInteger();
+ else if (pair[1].isReal())
+ s << std::fixed << std::setprecision(1) << pair[1].asReal();
+ else if (pair[1].isDate())
+ pair[1].asDate().toStream(s);
+ else
+ s << pair[1]; // just use default LLSD formatting
+ s << std::endl;
}
}
@@ -881,6 +908,9 @@ LLSD LLMemoryInfo::loadStatsArray()
// This implementation is derived from stream() code (as of 2011-06-29).
StatsArray stats;
+ // associate timestamp for analysis over time
+ stats.add("timestamp", LLDate::now());
+
#if LL_WINDOWS
MEMORYSTATUSEX state;
state.dwLength = sizeof(state);