Merge pull request #9245 from AndrewMeadows/avatars-per-second

measure avatar processing stats in Chrome trace framework
This commit is contained in:
samcake 2016-12-21 09:13:41 -08:00 committed by GitHub
commit 909f24c3e1
3 changed files with 27 additions and 1 deletions

View file

@ -75,6 +75,19 @@ namespace render {
}
}
static uint64_t timeProcessingJoints = 0;
static int32_t numJointsProcessed = 0;
float Avatar::getNumJointsProcessedPerSecond() {
float rate = 0.0f;
if (timeProcessingJoints > 0) {
rate = (float)(numJointsProcessed * USECS_PER_SECOND) / (float)timeProcessingJoints;
}
timeProcessingJoints = 0;
numJointsProcessed = 0;
return rate;
}
Avatar::Avatar(RigPointer rig) :
AvatarData(),
_skeletonOffset(0.0f),
@ -319,6 +332,7 @@ void Avatar::simulate(float deltaTime) {
}
}
uint64_t start = usecTimestampNow();
if (_shouldAnimate && !_shouldSkipRender && (avatarPositionInView || avatarMeshInView)) {
{
PerformanceTimer perfTimer("skeleton");
@ -345,6 +359,8 @@ void Avatar::simulate(float deltaTime) {
PerformanceTimer perfTimer("skeleton");
_skeletonModel->simulate(deltaTime, false);
}
timeProcessingJoints += usecTimestampNow() - start;
numJointsProcessed += _jointData.size();
// update animation for display name fade in/out
if ( _displayNameTargetAlpha != _displayNameAlpha) {

View file

@ -57,6 +57,8 @@ class Avatar : public AvatarData {
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
public:
static float getNumJointsProcessedPerSecond();
explicit Avatar(RigPointer rig = nullptr);
~Avatar();

View file

@ -25,13 +25,13 @@
#endif
#include <AvatarData.h>
#include <PerfStat.h>
#include <RegisteredMetaTypes.h>
#include <Rig.h>
#include <SettingHandle.h>
#include <UsersScriptingInterface.h>
#include <UUID.h>
#include <AvatarData.h>
#include "Application.h"
#include "Avatar.h"
@ -124,6 +124,9 @@ void AvatarManager::updateMyAvatar(float deltaTime) {
}
}
Q_LOGGING_CATEGORY(trace_simulation_avatar, "trace.simulation.avatar");
void AvatarManager::updateOtherAvatars(float deltaTime) {
// lock the hash for read to check the size
QReadLocker lock(&_hashLock);
@ -143,6 +146,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
// simulate avatars
auto hashCopy = getHashCopy();
uint64_t start = usecTimestampNow();
AvatarHash::iterator avatarIterator = hashCopy.begin();
while (avatarIterator != hashCopy.end()) {
auto avatar = std::static_pointer_cast<Avatar>(avatarIterator.value());
@ -165,6 +169,10 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
// simulate avatar fades
simulateAvatarFades(deltaTime);
SAMPLE_PROFILE_COUNTER(0.1f, simulation_avatar, "NumAvatarsPerSec",
{ { "NumAvatarsPerSec", (float)(size() * USECS_PER_SECOND) / (float)(usecTimestampNow() - start) } });
SAMPLE_PROFILE_COUNTER(0.1f, simulation_avatar, "NumJointsPerSec", { { "NumJointsPerSec", Avatar::getNumJointsProcessedPerSecond() } });
}
void AvatarManager::postUpdate(float deltaTime) {