summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llpointer.h50
-rw-r--r--indra/llcommon/lltrace.h22
-rw-r--r--indra/llcommon/lltracerecording.cpp2
-rw-r--r--indra/llcommon/lltracerecording.h16
-rw-r--r--indra/newview/llfasttimerview.cpp4
5 files changed, 53 insertions, 41 deletions
diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h
index 6a3bbeb768..f03551045e 100644
--- a/indra/llcommon/llpointer.h
+++ b/indra/llcommon/llpointer.h
@@ -166,52 +166,52 @@ protected:
};
template<typename Type>
-class LLCopyOnWritePointer : public LLPointer<Type>
+class LLCopyOnWritePointer
{
public:
- typedef LLPointer<Type> ref_pointer_t;
typedef LLCopyOnWritePointer<Type> self_t;
LLCopyOnWritePointer()
- {
- }
+ {}
LLCopyOnWritePointer(Type* ptr)
- : LLPointer(ptr)
- {
- }
+ : mPointer(ptr)
+ {}
+
+ LLCopyOnWritePointer(LLPointer<Type>& ptr)
+ : mPointer(ptr)
+ {}
Type* write()
{
makeUnique();
- return mPointer;
+ return mPointer.get();
}
void makeUnique()
{
- if (mPointer && mPointer->getNumRefs() > 1)
+ if (mPointer.notNull() && mPointer.get()->getNumRefs() > 1)
{
- ref_pointer_t::assign(new Type(*mPointer));
+ mPointer = new Type(*mPointer.get());
}
}
- using ref_pointer_t::operator BOOL;
- using ref_pointer_t::operator bool;
- using ref_pointer_t::operator!;
-
- using ref_pointer_t::operator !=;
- using ref_pointer_t::operator ==;
- using LLPointer<Type>::operator =;
+ operator BOOL() const { return (BOOL)mPointer; }
+ operator bool() const { return (bool)mPointer; }
+ bool operator!() const { return !mPointer; }
+ bool isNull() const { return mPointer.isNull(); }
+ bool notNull() const { return mPointer.notNull(); }
- using LLPointer<Type>::operator <;
- using LLPointer<Type>::operator >;
-
-
- operator Type*() { return mPointer; }
- operator const Type*() const { return mPointer; }
- Type* operator->() { return mPointer; }
- const Type* operator->() const { return mPointer; }
+ bool operator !=(Type* ptr) const { return (mPointer.get() != ptr); }
+ bool operator ==(Type* ptr) const { return (mPointer.get() == ptr); }
+ bool operator ==(const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer == ptr.mPointer); }
+ bool operator < (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer < ptr.mPointer); }
+ bool operator > (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer > ptr.mPointer); }
+ operator const Type*() const { return mPointer.get(); }
+ const Type* operator->() const { return mPointer.get(); }
+protected:
+ LLPointer<Type> mPointer;
};
#endif
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index a6b1b227c9..6e6bb51e47 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -201,18 +201,27 @@ namespace LLTrace
}
private:
- ACCUMULATOR* mStorage;
- size_t mStorageSize;
- size_t mNextStorageSlot;
+ ACCUMULATOR* mStorage;
+ size_t mStorageSize;
+ size_t mNextStorageSlot;
static LLThreadLocalPointer<ACCUMULATOR> sPrimaryStorage;
};
template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage;
+ //TODO: replace with decltype when C++11 is enabled
+ template<typename T>
+ struct MeanValueType
+ {
+ typedef F64 type;
+ };
+
template<typename ACCUMULATOR>
class TraceType
: public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string>
{
public:
+ typedef typename MeanValueType<TraceType<ACCUMULATOR> >::type mean_t;
+
TraceType(const char* name, const char* description = NULL)
: LLInstanceTracker(name),
mName(name),
@@ -415,6 +424,13 @@ namespace LLTrace
U32 mCalls;
};
+
+ template<>
+ struct MeanValueType<TraceType<TimeBlockAccumulator> >
+ {
+ typedef LLUnit<LLUnits::Seconds, F64> type;
+ };
+
template<>
class TraceType<TimeBlockAccumulator::CallCountAspect>
: public TraceType<TimeBlockAccumulator>
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index 7ed7e57570..e9b3376dae 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -49,7 +49,7 @@ Recording::Recording()
Recording::Recording( const Recording& other )
{
- llassert(other.mCountsFloat.get() != NULL);
+ llassert(other.mCountsFloat.notNull());
mSamplingTimer = other.mSamplingTimer;
mElapsedSeconds = other.mElapsedSeconds;
mCountsFloat = other.mCountsFloat;
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index a3af215dd3..6fd1a105d3 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -326,36 +326,32 @@ namespace LLTrace
}
template <typename T>
- F64 getPeriodMean(const TraceType<T>& stat) const
+ typename TraceType<T>::mean_t getPeriodMean(const TraceType<T>& stat) const
{
- F64 mean = 0.0;
- F64 count = 0;
+ typename TraceType<T>::mean_t mean = 0.0;
for (S32 i = 0; i < mNumPeriods; i++)
{
if (mRecordingPeriods[i].getDuration() > 0.f)
{
- count++;
mean += mRecordingPeriods[i].getSum(stat);
}
}
- mean /= (F64)mNumPeriods;
+ mean /= mNumPeriods;
return mean;
}
template <typename T>
- F64 getPeriodMeanPerSec(const TraceType<T>& stat) const
+ typename TraceType<T>::mean_t getPeriodMeanPerSec(const TraceType<T>& stat) const
{
- F64 mean = 0.0;
- F64 count = 0;
+ typename TraceType<T>::mean_t mean = 0.0;
for (S32 i = 0; i < mNumPeriods; i++)
{
if (mRecordingPeriods[i].getDuration() > 0.f)
{
- count++;
mean += mRecordingPeriods[i].getPerSec(stat);
}
}
- mean /= count;
+ mean /= mNumPeriods;
return mean;
}
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index a06fac6bb6..704b914b78 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -501,7 +501,7 @@ void LLFastTimerView::draw()
}
else
{
- ms = frame_recording.getPeriodMean(*idp);
+ ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
calls = frame_recording.getPeriodMean(idp->callCount());
}
@@ -511,7 +511,7 @@ void LLFastTimerView::draw()
}
else
{
- tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms);
+ tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
}
dx = (texth+4) + idp->getDepth()*8;