summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/llerror.cpp12
-rwxr-xr-xindra/llcommon/llerror.h2
-rwxr-xr-xindra/llcommon/llfasttimer.cpp10
-rwxr-xr-xindra/llcommon/llfasttimer.h2
-rwxr-xr-xindra/llcommon/llmemory.cpp18
-rwxr-xr-xindra/llcommon/llmemory.h17
-rwxr-xr-xindra/llcommon/llsys.cpp24
-rwxr-xr-xindra/llcommon/llsys.h6
-rwxr-xr-xindra/llcommon/lltimer.cpp2
-rw-r--r--indra/llcommon/lltraceaccumulators.h6
-rw-r--r--indra/llcommon/lltracerecording.cpp62
-rw-r--r--indra/llcommon/lltracerecording.h58
-rw-r--r--indra/llcommon/llunit.h189
-rw-r--r--indra/llcommon/tests/llunits_test.cpp2
14 files changed, 299 insertions, 111 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 6f128d0a20..1b1aada8c1 100755
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -449,7 +449,7 @@ namespace LLError
mTimeFunction(NULL),
mFileRecorder(NULL),
mFixedBufferRecorder(NULL),
- mShouldLogCallCounter(NULL)
+ mShouldLogCallCounter(0)
{}
~Settings()
@@ -548,12 +548,12 @@ namespace LLError
#else
#if LL_LINUX
// gross, but typeid comparison seems to always fail here with gcc4.1
- if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name()))
+ if (0 != strcmp(mClassInfo.name(), typeid(NoClassInfo).name()))
#else
- if (site.mClassInfo != typeid(NoClassInfo))
+ if (mClassInfo != typeid(NoClassInfo))
#endif // LL_LINUX
{
- mFunctionString = className(site.mClassInfo) + "::";
+ mFunctionString = className(mClassInfo) + "::";
}
#endif
mFunctionString += std::string(mFunction) + ":";
@@ -1065,8 +1065,8 @@ namespace LLError
s.mShouldLogCallCounter++;
- std::string& class_name = className(site.mClassInfo);
- std::string& function_name = functionName(site.mFunction);
+ const std::string& class_name = className(site.mClassInfo);
+ std::string function_name = functionName(site.mFunction);
#if LL_LINUX
// gross, but typeid comparison seems to always fail here with gcc4.1
if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name()))
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index 7810676388..af76a7653a 100755
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -308,7 +308,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
#define lllog(level, once, ...) \
do { \
const char* tags[] = {"", ##__VA_ARGS__}; \
- size_t tag_count = LL_ARRAY_SIZE(tags) - 1; \
+ ::size_t tag_count = LL_ARRAY_SIZE(tags) - 1; \
static LLError::CallSite _site( \
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), __FUNCTION__, once, &tags[1], tag_count);\
if (LL_UNLIKELY(_site.shouldLog())) \
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 8f86a1dfbc..5f92c66f47 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -339,7 +339,7 @@ void TimeBlock::logStats()
}
call_count++;
- LLUnit<F64, LLUnits::Seconds> total_time(0);
+ F64Seconds total_time(0);
LLSD sd;
{
@@ -382,11 +382,11 @@ void TimeBlock::dumpCurTimes()
++it)
{
TimeBlock* timerp = (*it);
- LLUnit<F64, LLUnits::Seconds> total_time = last_frame_recording.getSum(*timerp);
+ F64Seconds total_time = last_frame_recording.getSum(*timerp);
U32 num_calls = last_frame_recording.getSum(timerp->callCount());
// Don't bother with really brief times, keep output concise
- if (total_time < LLUnits::Milliseconds::fromValue(0.1f)) continue;
+ if (total_time < F32Milliseconds(0.1f)) continue;
std::ostringstream out_str;
TimeBlock* parent_timerp = timerp;
@@ -466,11 +466,11 @@ void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other )
}
}
-LLUnit<F64, LLUnits::Seconds> BlockTimer::getElapsedTime()
+F64Seconds BlockTimer::getElapsedTime()
{
U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime;
- return LLUnits::Seconds::fromValue((F64)total_time / (F64)TimeBlock::countsPerSecond());
+ return F64Seconds((F64)total_time / (F64)TimeBlock::countsPerSecond());
}
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 73c40749ed..ccf71c3f4c 100755
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -48,7 +48,7 @@ public:
BlockTimer(TimeBlock& timer);
~BlockTimer();
- LLUnit<F64, LLUnits::Seconds> getElapsedTime();
+ F64Seconds getElapsedTime();
private:
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index a9256124f2..c59b61471a 100755
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -47,11 +47,11 @@
//static
char* LLMemory::reserveMem = 0;
-U32 LLMemory::sAvailPhysicalMemInKB = U32_MAX ;
-U32 LLMemory::sMaxPhysicalMemInKB = 0;
-U32 LLMemory::sAllocatedMemInKB = 0;
-U32 LLMemory::sAllocatedPageSizeInKB = 0 ;
-U32 LLMemory::sMaxHeapSizeInKB = U32_MAX ;
+U32Kibibytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
+U32Kibibytes LLMemory::sMaxPhysicalMemInKB(0);
+U32Kibibytes LLMemory::sAllocatedMemInKB(0);
+U32Kibibytes LLMemory::sAllocatedPageSizeInKB(0);
+U32Kibibytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
#if __DEBUG_PRIVATE_MEM__
@@ -116,7 +116,7 @@ void LLMemory::updateMemoryInfo()
sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ;
sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ;
- U32 avail_phys, avail_virtual;
+ U32Kibibytes avail_phys, avail_virtual;
LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ;
sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB);
@@ -232,19 +232,19 @@ bool LLMemory::isMemoryPoolLow()
}
//static
-U32 LLMemory::getAvailableMemKB()
+U32Kibibytes LLMemory::getAvailableMemKB()
{
return sAvailPhysicalMemInKB ;
}
//static
-U32 LLMemory::getMaxMemKB()
+U32Kibibytes LLMemory::getMaxMemKB()
{
return sMaxPhysicalMemInKB ;
}
//static
-U32 LLMemory::getAllocatedMemKB()
+U32Kibibytes LLMemory::getAllocatedMemKB()
{
return sAllocatedMemInKB ;
}
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index a24d97576f..c45c7ed213 100755
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,6 +27,7 @@
#define LLMEMORY_H
#include "linden_common.h"
+#include "llunit.h"
#if !LL_WINDOWS
#include <stdint.h>
#endif
@@ -170,17 +171,17 @@ public:
static void logMemoryInfo(BOOL update = FALSE);
static bool isMemoryPoolLow();
- static U32 getAvailableMemKB() ;
- static U32 getMaxMemKB() ;
- static U32 getAllocatedMemKB() ;
+ static U32Kibibytes getAvailableMemKB() ;
+ static U32Kibibytes getMaxMemKB() ;
+ static U32Kibibytes getAllocatedMemKB() ;
private:
static char* reserveMem;
- static U32 sAvailPhysicalMemInKB ;
- static U32 sMaxPhysicalMemInKB ;
- static U32 sAllocatedMemInKB;
- static U32 sAllocatedPageSizeInKB ;
+ static U32Kibibytes sAvailPhysicalMemInKB ;
+ static U32Kibibytes sMaxPhysicalMemInKB ;
+ static U32Kibibytes sAllocatedMemInKB;
+ static U32Kibibytes sAllocatedPageSizeInKB ;
- static U32 sMaxHeapSizeInKB;
+ static U32Kibibytes sMaxHeapSizeInKB;
static BOOL sEnableMemoryFailurePrevention;
};
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index cad02f491a..8f7e60fb68 100755
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -832,7 +832,7 @@ LLMemoryInfo::LLMemoryInfo()
}
#if LL_WINDOWS
-static U32 LLMemoryAdjustKBResult(U32 inKB)
+static U32Kibibytes LLMemoryAdjustKBResult(U32Kibibytes inKB)
{
// Moved this here from llfloaterabout.cpp
@@ -843,16 +843,16 @@ static U32 LLMemoryAdjustKBResult(U32 inKB)
// returned from the GetMemoryStatusEx function. Here we keep the
// original adjustment from llfoaterabout.cpp until this can be
// fixed somehow.
- inKB += 1024;
+ inKB += U32Mibibytes(1);
return inKB;
}
#endif
-U32 LLMemoryInfo::getPhysicalMemoryKB() const
+U32Kibibytes LLMemoryInfo::getPhysicalMemoryKB() const
{
#if LL_WINDOWS
- return LLMemoryAdjustKBResult(mStatsMap["Total Physical KB"].asInteger());
+ return LLMemoryAdjustKBResult(U32Kibibytes(mStatsMap["Total Physical KB"].asInteger()));
#elif LL_DARWIN
// This might work on Linux as well. Someone check...
@@ -862,17 +862,17 @@ U32 LLMemoryInfo::getPhysicalMemoryKB() const
size_t len = sizeof(phys);
sysctl(mib, 2, &phys, &len, NULL, 0);
- return (U32)(phys >> 10);
+ return U32Bytes(phys);
#elif LL_LINUX
U64 phys = 0;
phys = (U64)(getpagesize()) * (U64)(get_phys_pages());
- return (U32)(phys >> 10);
+ return U32Bytes(phys);
#elif LL_SOLARIS
U64 phys = 0;
phys = (U64)(getpagesize()) * (U64)(sysconf(_SC_PHYS_PAGES));
- return (U32)(phys >> 10);
+ return U32Bytes(phys);
#else
return 0;
@@ -880,24 +880,24 @@ U32 LLMemoryInfo::getPhysicalMemoryKB() const
#endif
}
-U32 LLMemoryInfo::getPhysicalMemoryClamped() const
+U32Bytes LLMemoryInfo::getPhysicalMemoryClamped() const
{
// Return the total physical memory in bytes, but clamp it
// to no more than U32_MAX
- U32 phys_kb = getPhysicalMemoryKB();
+ U32Bytes phys_kb = getPhysicalMemoryKB();
if (phys_kb >= 4194304 /* 4GB in KB */)
{
- return U32_MAX;
+ return U32Bytes(U32_MAX);
}
else
{
- return phys_kb << 10;
+ return phys_kb;
}
}
//static
-void LLMemoryInfo::getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb)
+void LLMemoryInfo::getAvailableMemoryKB(U32Kibibytes& avail_physical_mem_kb, U32Kibibytes& avail_virtual_mem_kb)
{
#if LL_WINDOWS
// Sigh, this shouldn't be a static method, then we wouldn't have to
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index aa60fc9b2e..ad4f243d05 100755
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -112,15 +112,15 @@ public:
LLMemoryInfo(); ///< Default constructor
void stream(std::ostream& s) const; ///< output text info to s
- U32 getPhysicalMemoryKB() const; ///< Memory size in KiloBytes
+ U32Kibibytes getPhysicalMemoryKB() const;
/*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will
** be returned.
*/
- U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
+ U32Bytes getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
//get the available memory infomation in KiloBytes.
- static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb);
+ static void getAvailableMemoryKB(U32Kibibytes& avail_physical_mem_kb, U32Kibibytes& avail_virtual_mem_kb);
// Retrieve a map of memory statistics. The keys of the map are platform-
// dependent. The values are in kilobytes to try to avoid integer overflow.
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index a2c5f3d699..74f3a7f587 100755
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -262,7 +262,7 @@ LLUnitImplicit<U64, LLUnits::Microseconds> totalTime()
}
// Return the total clock tick count in microseconds.
- return LLUnits::Microseconds::fromValue(gTotalTimeClockCount*gClocksToMicroseconds);
+ return U64Microseconds(gTotalTimeClockCount*gClocksToMicroseconds);
}
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index ef73bd3091..73da6bd2d8 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -418,7 +418,7 @@ namespace LLTrace
class TimeBlockAccumulator
{
public:
- typedef LLUnit<F64, LLUnits::Seconds> value_t;
+ typedef F64Seconds value_t;
typedef TimeBlockAccumulator self_t;
// fake classes that allows us to view different facets of underlying statistic
@@ -429,7 +429,7 @@ namespace LLTrace
struct SelfTimeFacet
{
- typedef LLUnit<F64, LLUnits::Seconds> value_t;
+ typedef F64Seconds value_t;
};
TimeBlockAccumulator();
@@ -492,7 +492,7 @@ namespace LLTrace
struct ChildMemFacet
{
- typedef LLUnit<F64, LLUnits::Bytes> value_t;
+ typedef F64Bytes value_t;
};
MemStatAccumulator()
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index 42d97ce314..bc98eebf31 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -95,7 +95,7 @@ void Recording::handleReset()
{
mBuffers.write()->reset();
- mElapsedSeconds = LLUnits::Seconds::fromValue(0.0);
+ mElapsedSeconds = F64Seconds(0.0);
mSamplingTimer.reset();
}
@@ -128,17 +128,17 @@ void Recording::appendRecording( Recording& other )
mElapsedSeconds += other.mElapsedSeconds;
}
-LLUnit<F64, LLUnits::Seconds> Recording::getSum(const TraceType<TimeBlockAccumulator>& stat)
+F64Seconds Recording::getSum(const TraceType<TimeBlockAccumulator>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
+ return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
/ (F64)LLTrace::TimeBlock::countsPerSecond());
}
-LLUnit<F64, LLUnits::Seconds> Recording::getSum(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat)
+F64Seconds Recording::getSum(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond());
+ return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond());
}
@@ -147,19 +147,19 @@ U32 Recording::getSum(const TraceType<TimeBlockAccumulator::CallCountFacet>& sta
return mBuffers->mStackTimers[stat.getIndex()].mCalls;
}
-LLUnit<F64, LLUnits::Seconds> Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat)
+F64Seconds Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
+ return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
/ ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()));
}
-LLUnit<F64, LLUnits::Seconds> Recording::getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat)
+F64Seconds Recording::getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter)
+ return F64Seconds((F64)(accumulator.mSelfTimeCounter)
/ ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()));
}
@@ -168,54 +168,54 @@ F32 Recording::getPerSec(const TraceType<TimeBlockAccumulator::CallCountFacet>&
return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value();
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMin(const TraceType<MemStatAccumulator>& stat)
+F64Bytes Recording::getMin(const TraceType<MemStatAccumulator>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMin());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMean(const TraceType<MemStatAccumulator>& stat)
+F64Bytes Recording::getMean(const TraceType<MemStatAccumulator>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMean());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMax(const TraceType<MemStatAccumulator>& stat)
+F64Bytes Recording::getMax(const TraceType<MemStatAccumulator>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMax());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getStandardDeviation(const TraceType<MemStatAccumulator>& stat)
+F64Bytes Recording::getStandardDeviation(const TraceType<MemStatAccumulator>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getLastValue(const TraceType<MemStatAccumulator>& stat)
+F64Bytes Recording::getLastValue(const TraceType<MemStatAccumulator>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMin(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
+F64Bytes Recording::getMin(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMean(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
+F64Bytes Recording::getMean(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getMax(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
+F64Bytes Recording::getMax(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getStandardDeviation(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
+F64Bytes Recording::getStandardDeviation(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation());
}
-LLUnit<F64, LLUnits::Bytes> Recording::getLastValue(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
+F64Bytes Recording::getLastValue(const TraceType<MemStatAccumulator::ChildMemFacet>& stat)
{
- return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue());
+ return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue());
}
U32 Recording::getSum(const TraceType<MemStatAccumulator::AllocationCountFacet>& stat)
@@ -427,9 +427,9 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
getCurRecording().setPlayState(getPlayState());
}
-LLUnit<F64, LLUnits::Seconds> PeriodicRecording::getDuration() const
+F64Seconds PeriodicRecording::getDuration() const
{
- LLUnit<F64, LLUnits::Seconds> duration;
+ F64Seconds duration;
size_t num_periods = mRecordingPeriods.size();
for (size_t i = 1; i <= num_periods; i++)
{
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 3722a61327..f5fb2bf561 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -166,26 +166,26 @@ namespace LLTrace
void makeUnique() { mBuffers.makeUnique(); }
// Timer accessors
- LLUnit<F64, LLUnits::Seconds> getSum(const TraceType<TimeBlockAccumulator>& stat);
- LLUnit<F64, LLUnits::Seconds> getSum(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat);
+ F64Seconds getSum(const TraceType<TimeBlockAccumulator>& stat);
+ F64Seconds getSum(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat);
U32 getSum(const TraceType<TimeBlockAccumulator::CallCountFacet>& stat);
- LLUnit<F64, LLUnits::Seconds> getPerSec(const TraceType<TimeBlockAccumulator>& stat);
- LLUnit<F64, LLUnits::Seconds> getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat);
+ F64Seconds getPerSec(const TraceType<TimeBlockAccumulator>& stat);
+ F64Seconds getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeFacet>& stat);
F32 getPerSec(const TraceType<TimeBlockAccumulator::CallCountFacet>& stat);
// Memory accessors
- LLUnit<F64, LLUnits::Bytes> getMin(const TraceType<MemStatAccumulator>& stat);
- LLUnit<F64, LLUnits::Bytes> getMean(const TraceType<MemStatAccumulator>& stat);
- LLUnit<F64, LLUnits::Bytes> getMax(const TraceType<MemStatAccumulator>& stat);
- LLUnit<F64, LLUnits::Bytes> getStandardDeviation(const TraceType<MemStatAccumulator>& stat);
- LLUnit<F64, LLUnits::Bytes> getLastValue(const TraceType<MemStatAccumulator>& stat);
-
- LLUnit<F64, LLUnits::Bytes> getMin(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
- LLUnit<F64, LLUnits::Bytes> getMean(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
- LLUnit<F64, LLUnits::Bytes> getMax(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
- LLUnit<F64, LLUnits::Bytes> getStandardDeviation(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
- LLUnit<F64, LLUnits::Bytes> getLastValue(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
+ F64Bytes getMin(const TraceType<MemStatAccumulator>& stat);
+ F64Bytes getMean(const TraceType<MemStatAccumulator>& stat);
+ F64Bytes getMax(const TraceType<MemStatAccumulator>& stat);
+ F64Bytes getStandardDeviation(const TraceType<MemStatAccumulator>& stat);
+ F64Bytes getLastValue(const TraceType<MemStatAccumulator>& stat);
+
+ F64Bytes getMin(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
+ F64Bytes getMean(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
+ F64Bytes getMax(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
+ F64Bytes getStandardDeviation(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
+ F64Bytes getLastValue(const TraceType<MemStatAccumulator::ChildMemFacet>& stat);
U32 getSum(const TraceType<MemStatAccumulator::AllocationCountFacet>& stat);
U32 getSum(const TraceType<MemStatAccumulator::DeallocationCountFacet>& stat);
@@ -295,7 +295,7 @@ namespace LLTrace
U32 getSampleCount(const TraceType<EventAccumulator>& stat);
- LLUnit<F64, LLUnits::Seconds> getDuration() const { return mElapsedSeconds; }
+ F64Seconds getDuration() const { return mElapsedSeconds; }
protected:
friend class ThreadRecorder;
@@ -310,7 +310,7 @@ namespace LLTrace
class ThreadRecorder* getThreadRecorder();
LLTimer mSamplingTimer;
- LLUnit<F64, LLUnits::Seconds> mElapsedSeconds;
+ F64Seconds mElapsedSeconds;
LLCopyOnWritePointer<AccumulatorBufferGroup> mBuffers;
bool mInHandOff;
@@ -325,7 +325,7 @@ namespace LLTrace
void nextPeriod();
size_t getNumRecordedPeriods() { return mNumPeriods; }
- LLUnit<F64, LLUnits::Seconds> getDuration() const;
+ F64Seconds getDuration() const;
void appendPeriodicRecording(PeriodicRecording& other);
void appendRecording(Recording& recording);
@@ -347,7 +347,7 @@ namespace LLTrace
for (S32 i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
- num_samples += Recording.getSampleCount(stat);
+ num_samples += recording.getSampleCount(stat);
}
return num_samples;
}
@@ -366,7 +366,7 @@ namespace LLTrace
typename T::value_t min_val = std::numeric_limits<typename T::value_t>::max();
for (S32 i = 1; i <= num_periods; i++)
{
- Recording& recording = getPrevRecording(i)
+ Recording& recording = getPrevRecording(i);
min_val = llmin(min_val, recording.getSum(stat));
}
return min_val;
@@ -398,7 +398,7 @@ namespace LLTrace
size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
- RelatedTypes<typename T::value_t>::fractional_t min_val = std::numeric_limits<F64>::max();
+ typename RelatedTypes<typename T::value_t>::fractional_t min_val = std::numeric_limits<F64>::max();
for (S32 i = 1; i <= num_periods; i++)
{
Recording& recording = getPrevRecording(i);
@@ -485,7 +485,7 @@ namespace LLTrace
size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
- typename RelatedTypes<T::value_t>::fractional_t mean = 0;
+ typename RelatedTypes<typename T::value_t>::fractional_t mean(0);
for (S32 i = 1; i <= num_periods; i++)
{
@@ -495,9 +495,9 @@ namespace LLTrace
mean += recording.getSum(stat);
}
}
- return RelatedTypes<T::value_t>::fractional_t(num_periods
- ? mean / num_periods
- : NaN);
+ return (num_periods
+ ? typename RelatedTypes<typename T::value_t>::fractional_t(mean / num_periods)
+ : typename RelatedTypes<typename T::value_t>::fractional_t(NaN));
}
template<typename T>
@@ -525,7 +525,7 @@ namespace LLTrace
size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
- typename RelatedTypes<T::value_t>::fractional_t mean = 0;
+ typename RelatedTypes<typename T::value_t>::fractional_t mean = 0;
for (S32 i = 1; i <= num_periods; i++)
{
@@ -536,9 +536,9 @@ namespace LLTrace
}
}
- return RelatedTypes<T::value_t>::fractional_t(num_periods
- ? mean / num_periods
- : NaN);
+ return (num_periods
+ ? typename RelatedTypes<typename T::value_t>::fractional_t(mean / num_periods)
+ : typename RelatedTypes<typename T::value_t>::fractional_t(NaN));
}
template<typename T>
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index b135be48fa..b62bebc440 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -39,7 +39,7 @@ struct LLUnit
typedef STORAGE_TYPE storage_t;
// value initialization
- LLUnit(storage_t value = storage_t())
+ explicit LLUnit(storage_t value = storage_t())
: mValue(value)
{}
@@ -643,7 +643,58 @@ LL_DECLARE_DERIVED_UNIT(Megabytes, * 1000, Gigabytes, "GB");
LL_DECLARE_DERIVED_UNIT(Bytes, * 1024, Kibibytes, "KiB");
LL_DECLARE_DERIVED_UNIT(Kibibytes, * 1024, Mibibytes, "MiB");
LL_DECLARE_DERIVED_UNIT(Mibibytes, * 1024, Gibibytes, "GiB");
+}
+
+typedef LLUnit<F32, LLUnits::Bytes> F32Bytes;
+typedef LLUnit<F32, LLUnits::Kilobytes> F32Kilobytes;
+typedef LLUnit<F32, LLUnits::Megabytes> F32Megabytes;
+typedef LLUnit<F32, LLUnits::Gigabytes> F32Gigabytes;
+typedef LLUnit<F32, LLUnits::Kibibytes> F32Kibibytes;
+typedef LLUnit<F32, LLUnits::Mibibytes> F32Mibibytes;
+typedef LLUnit<F32, LLUnits::Gibibytes> F32Gibibytes;
+
+typedef LLUnit<F64, LLUnits::Bytes> F64Bytes;
+typedef LLUnit<F64, LLUnits::Kilobytes> F64Kilobytes;
+typedef LLUnit<F64, LLUnits::Megabytes> F64Megabytes;
+typedef LLUnit<F64, LLUnits::Gigabytes> F64Gigabytes;
+typedef LLUnit<F64, LLUnits::Kibibytes> F64Kibibytes;
+typedef LLUnit<F64, LLUnits::Mibibytes> F64Mibibytes;
+typedef LLUnit<F64, LLUnits::Gibibytes> F64Gibibytes;
+
+typedef LLUnit<S32, LLUnits::Bytes> S32Bytes;
+typedef LLUnit<S32, LLUnits::Kilobytes> S32Kilobytes;
+typedef LLUnit<S32, LLUnits::Megabytes> S32Megabytes;
+typedef LLUnit<S32, LLUnits::Gigabytes> S32Gigabytes;
+typedef LLUnit<S32, LLUnits::Kibibytes> S32Kibibytes;
+typedef LLUnit<S32, LLUnits::Mibibytes> S32Mibibytes;
+typedef LLUnit<S32, LLUnits::Gibibytes> S32Gibibytes;
+
+typedef LLUnit<U32, LLUnits::Bytes> U32Bytes;
+typedef LLUnit<U32, LLUnits::Kilobytes> U32Kilobytes;
+typedef LLUnit<U32, LLUnits::Megabytes> U32Megabytes;
+typedef LLUnit<U32, LLUnits::Gigabytes> U32Gigabytes;
+typedef LLUnit<U32, LLUnits::Kibibytes> U32Kibibytes;
+typedef LLUnit<U32, LLUnits::Mibibytes> U32Mibibytes;
+typedef LLUnit<U32, LLUnits::Gibibytes> U32Gibibytes;
+
+typedef LLUnit<S64, LLUnits::Bytes> S64Bytes;
+typedef LLUnit<S64, LLUnits::Kilobytes> S64Kilobytes;
+typedef LLUnit<S64, LLUnits::Megabytes> S64Megabytes;
+typedef LLUnit<S64, LLUnits::Gigabytes> S64Gigabytes;
+typedef LLUnit<S64, LLUnits::Kibibytes> S64Kibibytes;
+typedef LLUnit<S64, LLUnits::Mibibytes> S64Mibibytes;
+typedef LLUnit<S64, LLUnits::Gibibytes> S64Gibibytes;
+
+typedef LLUnit<U64, LLUnits::Bytes> U64Bytes;
+typedef LLUnit<U64, LLUnits::Kilobytes> U64Kilobytes;
+typedef LLUnit<U64, LLUnits::Megabytes> U64Megabytes;
+typedef LLUnit<U64, LLUnits::Gigabytes> U64Gigabytes;
+typedef LLUnit<U64, LLUnits::Kibibytes> U64Kibibytes;
+typedef LLUnit<U64, LLUnits::Mibibytes> U64Mibibytes;
+typedef LLUnit<U64, LLUnits::Gibibytes> U64Gibibytes;
+namespace LLUnits
+{
LL_DECLARE_DERIVED_UNIT(Bytes, / 8, Bits, "b");
LL_DECLARE_DERIVED_UNIT(Bits, * 1000, Kilobits, "Kb");
LL_DECLARE_DERIVED_UNIT(Kilobits, * 1000, Megabits, "Mb");
@@ -651,7 +702,58 @@ LL_DECLARE_DERIVED_UNIT(Megabits, * 1000, Gigabits, "Gb");
LL_DECLARE_DERIVED_UNIT(Bits, * 1024, Kibibits, "Kib");
LL_DECLARE_DERIVED_UNIT(Kibibits, * 1024, Mibibits, "Mib");
LL_DECLARE_DERIVED_UNIT(Mibibits, * 1024, Gibibits, "Gib");
+}
+
+typedef LLUnit<F32, LLUnits::Bits> F32Bits;
+typedef LLUnit<F32, LLUnits::Kilobits> F32Kilobits;
+typedef LLUnit<F32, LLUnits::Megabits> F32Megabits;
+typedef LLUnit<F32, LLUnits::Gigabits> F32Gigabits;
+typedef LLUnit<F32, LLUnits::Kibibits> F32Kibibits;
+typedef LLUnit<F32, LLUnits::Mibibits> F32Mibibits;
+typedef LLUnit<F32, LLUnits::Gibibits> F32Gibibits;
+
+typedef LLUnit<F64, LLUnits::Bits> F64Bits;
+typedef LLUnit<F64, LLUnits::Kilobits> F64Kilobits;
+typedef LLUnit<F64, LLUnits::Megabits> F64Megabits;
+typedef LLUnit<F64, LLUnits::Gigabits> F64Gigabits;
+typedef LLUnit<F64, LLUnits::Kibibits> F64Kibibits;
+typedef LLUnit<F64, LLUnits::Mibibits> F64Mibibits;
+typedef LLUnit<F64, LLUnits::Gibibits> F64Gibibits;
+
+typedef LLUnit<S32, LLUnits::Bits> S32Bits;
+typedef LLUnit<S32, LLUnits::Kilobits> S32Kilobits;
+typedef LLUnit<S32, LLUnits::Megabits> S32Megabits;
+typedef LLUnit<S32, LLUnits::Gigabits> S32Gigabits;
+typedef LLUnit<S32, LLUnits::Kibibits> S32Kibibits;
+typedef LLUnit<S32, LLUnits::Mibibits> S32Mibibits;
+typedef LLUnit<S32, LLUnits::Gibibits> S32Gibibits;
+
+typedef LLUnit<U32, LLUnits::Bits> U32Bits;
+typedef LLUnit<U32, LLUnits::Kilobits> U32Kilobits;
+typedef LLUnit<U32, LLUnits::Megabits> U32Megabits;
+typedef LLUnit<U32, LLUnits::Gigabits> U32Gigabits;
+typedef LLUnit<U32, LLUnits::Kibibits> U32Kibibits;
+typedef LLUnit<U32, LLUnits::Mibibits> U32Mibibits;
+typedef LLUnit<U32, LLUnits::Gibibits> U32Gibibits;
+
+typedef LLUnit<S64, LLUnits::Bits> S64Bits;
+typedef LLUnit<S64, LLUnits::Kilobits> S64Kilobits;
+typedef LLUnit<S64, LLUnits::Megabits> S64Megabits;
+typedef LLUnit<S64, LLUnits::Gigabits> S64Gigabits;
+typedef LLUnit<S64, LLUnits::Kibibits> S64Kibibits;
+typedef LLUnit<S64, LLUnits::Mibibits> S64Mibibits;
+typedef LLUnit<S64, LLUnits::Gibibits> S64Gibibits;
+
+typedef LLUnit<U64, LLUnits::Bits> U64Bits;
+typedef LLUnit<U64, LLUnits::Kilobits> U64Kilobits;
+typedef LLUnit<U64, LLUnits::Megabits> U64Megabits;
+typedef LLUnit<U64, LLUnits::Gigabits> U64Gigabits;
+typedef LLUnit<U64, LLUnits::Kibibits> U64Kibibits;
+typedef LLUnit<U64, LLUnits::Mibibits> U64Mibibits;
+typedef LLUnit<U64, LLUnits::Gibibits> U64Gibibits;
+namespace LLUnits
+{
LL_DECLARE_BASE_UNIT(Seconds, "s");
LL_DECLARE_DERIVED_UNIT(Seconds, * 60, Minutes, "min");
LL_DECLARE_DERIVED_UNIT(Minutes, * 60, Hours, "h");
@@ -659,12 +761,97 @@ LL_DECLARE_DERIVED_UNIT(Hours, * 24, Days, "d");
LL_DECLARE_DERIVED_UNIT(Seconds, / 1000, Milliseconds, "ms");
LL_DECLARE_DERIVED_UNIT(Milliseconds, / 1000, Microseconds, "\x09\x3cs");
LL_DECLARE_DERIVED_UNIT(Microseconds, / 1000, Nanoseconds, "ns");
+}
+typedef LLUnit<F32, LLUnits::Seconds> F32Seconds;
+typedef LLUnit<F32, LLUnits::Minutes> F32Minutes;
+typedef LLUnit<F32, LLUnits::Hours> F32Hours;
+typedef LLUnit<F32, LLUnits::Days> F32Days;
+typedef LLUnit<F32, LLUnits::Milliseconds> F32Milliseconds;
+typedef LLUnit<F32, LLUnits::Microseconds> F32Microseconds;
+typedef LLUnit<F32, LLUnits::Nanoseconds> F32Nanoseconds;
+
+typedef LLUnit<F64, LLUnits::Seconds> F64Seconds;
+typedef LLUnit<F64, LLUnits::Minutes> F64Minutes;
+typedef LLUnit<F64, LLUnits::Hours> F64Hours;
+typedef LLUnit<F64, LLUnits::Days> F64Days;
+typedef LLUnit<F64, LLUnits::Milliseconds> F64Milliseconds;
+typedef LLUnit<F64, LLUnits::Microseconds> F64Microseconds;
+typedef LLUnit<F64, LLUnits::Nanoseconds> F64Nanoseconds;
+
+typedef LLUnit<S32, LLUnits::Seconds> S32Seconds;
+typedef LLUnit<S32, LLUnits::Minutes> S32Minutes;
+typedef LLUnit<S32, LLUnits::Hours> S32Hours;
+typedef LLUnit<S32, LLUnits::Days> S32Days;
+typedef LLUnit<S32, LLUnits::Milliseconds> S32Milliseconds;
+typedef LLUnit<S32, LLUnits::Microseconds> S32Microseconds;
+typedef LLUnit<S32, LLUnits::Nanoseconds> S32Nanoseconds;
+
+typedef LLUnit<U32, LLUnits::Seconds> U32Seconds;
+typedef LLUnit<U32, LLUnits::Minutes> U32Minutes;
+typedef LLUnit<U32, LLUnits::Hours> U32Hours;
+typedef LLUnit<U32, LLUnits::Days> U32Days;
+typedef LLUnit<U32, LLUnits::Milliseconds> U32Milliseconds;
+typedef LLUnit<U32, LLUnits::Microseconds> U32Microseconds;
+typedef LLUnit<U32, LLUnits::Nanoseconds> U32Nanoseconds;
+
+typedef LLUnit<S64, LLUnits::Seconds> S64Seconds;
+typedef LLUnit<S64, LLUnits::Minutes> S64Minutes;
+typedef LLUnit<S64, LLUnits::Hours> S64Hours;
+typedef LLUnit<S64, LLUnits::Days> S64Days;
+typedef LLUnit<S64, LLUnits::Milliseconds> S64Milliseconds;
+typedef LLUnit<S64, LLUnits::Microseconds> S64Microseconds;
+typedef LLUnit<S64, LLUnits::Nanoseconds> S64Nanoseconds;
+
+typedef LLUnit<U64, LLUnits::Seconds> U64Seconds;
+typedef LLUnit<U64, LLUnits::Minutes> U64Minutes;
+typedef LLUnit<U64, LLUnits::Hours> U64Hours;
+typedef LLUnit<U64, LLUnits::Days> U64Days;
+typedef LLUnit<U64, LLUnits::Milliseconds> U64Milliseconds;
+typedef LLUnit<U64, LLUnits::Microseconds> U64Microseconds;
+typedef LLUnit<U64, LLUnits::Nanoseconds> U64Nanoseconds;
+
+namespace LLUnits
+{
LL_DECLARE_BASE_UNIT(Meters, "m");
LL_DECLARE_DERIVED_UNIT(Meters, * 1000, Kilometers, "km");
LL_DECLARE_DERIVED_UNIT(Meters, / 100, Centimeters, "cm");
LL_DECLARE_DERIVED_UNIT(Meters, / 1000, Millimeters, "mm");
+}
+
+typedef LLUnit<F32, LLUnits::Meters> F32Meters;
+typedef LLUnit<F32, LLUnits::Kilometers> F32Kilometers;
+typedef LLUnit<F32, LLUnits::Centimeters> F32Centimeters;
+typedef LLUnit<F32, LLUnits::Millimeters> F32Millimeters;
+
+typedef LLUnit<F64, LLUnits::Meters> F64Meters;
+typedef LLUnit<F64, LLUnits::Kilometers> F64Kilometers;
+typedef LLUnit<F64, LLUnits::Centimeters> F64Centimeters;
+typedef LLUnit<F64, LLUnits::Millimeters> F64Millimeters;
+
+typedef LLUnit<S32, LLUnits::Meters> S32Meters;
+typedef LLUnit<S32, LLUnits::Kilometers> S32Kilometers;
+typedef LLUnit<S32, LLUnits::Centimeters> S32Centimeters;
+typedef LLUnit<S32, LLUnits::Millimeters> S32Millimeters;
+typedef LLUnit<U32, LLUnits::Meters> U32Meters;
+typedef LLUnit<U32, LLUnits::Kilometers> U32Kilometers;
+typedef LLUnit<U32, LLUnits::Centimeters> U32Centimeters;
+typedef LLUnit<U32, LLUnits::Millimeters> U32Millimeters;
+
+typedef LLUnit<S64, LLUnits::Meters> S64Meters;
+typedef LLUnit<S64, LLUnits::Kilometers> S64Kilometers;
+typedef LLUnit<S64, LLUnits::Centimeters> S64Centimeters;
+typedef LLUnit<S64, LLUnits::Millimeters> S64Millimeters;
+
+typedef LLUnit<U64, LLUnits::Meters> U64Meters;
+typedef LLUnit<U64, LLUnits::Kilometers> U64Kilometers;
+typedef LLUnit<U64, LLUnits::Centimeters> U64Centimeters;
+typedef LLUnit<U64, LLUnits::Millimeters> U64Millimeters;
+
+namespace LLUnits
+{
+// rare units
LL_DECLARE_BASE_UNIT(Hertz, "Hz");
LL_DECLARE_DERIVED_UNIT(Hertz, * 1000, Kilohertz, "KHz");
LL_DECLARE_DERIVED_UNIT(Kilohertz, * 1000, Megahertz, "MHz");
diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp
index b0309585aa..8546bcbc54 100644
--- a/indra/llcommon/tests/llunits_test.cpp
+++ b/indra/llcommon/tests/llunits_test.cpp
@@ -112,7 +112,7 @@ namespace tut
void units_object_t::test<4>()
{
// exercise math operations
- LLUnit<F32, Quatloos> quatloos = 1.f;
+ LLUnit<F32, Quatloos> quatloos(1.f);
quatloos *= 4.f;
ensure(quatloos == 4);
quatloos = quatloos * 2;