From cc762ba60493a2dceba53929d10640a556a5e9ae Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Mon, 5 Mar 2012 14:19:39 -0500
Subject: SH-2970 WIP - simple LLSD metrics for self av

---
 indra/newview/llvoavatar.cpp     | 37 ++++++++++++++++++++++++-------------
 indra/newview/llvoavatar.h       |  2 +-
 indra/newview/llvoavatarself.cpp | 16 ++++++++++++++++
 indra/newview/llvoavatarself.h   |  1 +
 4 files changed, 42 insertions(+), 14 deletions(-)
 mode change 100644 => 100755 indra/newview/llvoavatarself.h

(limited to 'indra')

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 9249e0fa21..dbb9c218d3 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -797,6 +797,9 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c
 			<< " : " << comment
 			<< llendl;
 
+	LLSD metrics = gAgentAvatarp->metricsData();
+	llinfos << gAgentAvatarp->avString() << " metrics " << metrics << llendl;
+
 	if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
 	{
 		LLSD args;
@@ -807,17 +810,6 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c
 	}
 }
 
-// Dump avatar metrics data.
-// virtual
-LLSD LLVOAvatar::metricsData()
-{
-	LLSD result;
-	result["id"] = getID();
-	result["rez_status"] = getRezzedStatus();
-	result["is_self"] = isSelf();
-	return result;
-}
-
 //------------------------------------------------------------------------
 // LLVOAvatar::~LLVOAvatar()
 //------------------------------------------------------------------------
@@ -957,9 +949,9 @@ BOOL LLVOAvatar::hasGray() const
 S32 LLVOAvatar::getRezzedStatus() const
 {
 	if (getIsCloud()) return 0;
-	if (hasGray()) return 1;
 	if (isFullyTextured()) return 2;
-	return -1;
+	llassert(hasGray());
+	return 1; // gray
 }
 
 void LLVOAvatar::deleteLayerSetCaches(bool clearAll)
@@ -1008,6 +1000,22 @@ BOOL LLVOAvatar::areAllNearbyInstancesBaked(S32& grey_avatars)
 	return res;
 }
 
+// static
+void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
+{
+	counts.clear();
+	counts.resize(3);
+	for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
+		 iter != LLCharacter::sInstances.end(); ++iter)
+	{
+		LLVOAvatar* inst = (LLVOAvatar*) *iter;
+		if (!inst)
+			continue;
+		S32 rez_status = inst->getRezzedStatus();
+		counts[rez_status]++;
+	}
+}
+
 // static
 void LLVOAvatar::dumpBakedStatus()
 {
@@ -7733,6 +7741,9 @@ void LLVOAvatar::cullAvatarsByPixelArea()
 		}
 	}
 
+	// runway - this doesn't detect gray/grey state.
+	// think we just need to be checking self av since it's the only
+	// one with lltexlayer stuff.
 	S32 grey_avatars = 0;
 	if (LLVOAvatar::areAllNearbyInstancesBaked(grey_avatars))
 	{
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 9a9ba85eb2..d4166a66b2 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -524,6 +524,7 @@ public:
 
 	BOOL			isFullyBaked();
 	static BOOL		areAllNearbyInstancesBaked(S32& grey_avatars);
+	static void		getNearbyRezzedStats(std::vector<S32>& counts);
 
 	//--------------------------------------------------------------------
 	// Baked textures
@@ -989,7 +990,6 @@ private:
 public:
 	void 			debugAvatarRezTime(std::string notification_name, std::string comment = "");
 	F32				debugGetExistenceTimeElapsedF32() const { return mDebugExistenceTimer.getElapsedTimeF32(); }
-	LLSD			metricsData();
 
 protected:
 	LLFrameTimer	mRuthDebugTimer; // For tracking how long it takes for av to rez
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 467961c55e..0a60ef4fff 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2054,6 +2054,22 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const
 	return text;
 }
 
+// Dump avatar metrics data.
+LLSD LLVOAvatarSelf::metricsData()
+{
+	LLSD result;
+	result["id"] = getID();
+	result["rez_status"] = getRezzedStatus();
+	result["is_self"] = isSelf();
+	std::vector<S32> rez_counts;
+	LLVOAvatar::getNearbyRezzedStats(rez_counts);
+	result["nearby_cloud"] = rez_counts[0];
+	result["nearby_gray"] = rez_counts[1];
+	result["nearby_textured"] = rez_counts[2];
+	
+	return result;
+}
+
 const LLUUID& LLVOAvatarSelf::grabBakedTexture(EBakedTextureIndex baked_index) const
 {
 	if (canGrabBakedTexture(baked_index))
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
old mode 100644
new mode 100755
index 6aadf4533e..aaceff933a
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -369,6 +369,7 @@ public:
 	const LLTexLayerSet*  	debugGetLayerSet(LLVOAvatarDefines::EBakedTextureIndex index) const { return mBakedTextureDatas[index].mTexLayerSet; }
 	const std::string		debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
 	const std::string		debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
+	LLSD					metricsData();
 private:
 	LLFrameTimer    		mDebugSelfLoadTimer;
 	F32						mDebugTimeWearablesLoaded;
-- 
cgit v1.2.3