Skip to content
Snippets Groups Projects
Commit 367e0e4c authored by Richard Linden's avatar Richard Linden
Browse files

merge

parents 5ea07f47 dd4f75a7
No related branches found
No related tags found
No related merge requests found
...@@ -532,7 +532,7 @@ S32 Recording::getSampleCount( const StatType<EventAccumulator>& stat ) ...@@ -532,7 +532,7 @@ S32 Recording::getSampleCount( const StatType<EventAccumulator>& stat )
PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state)
: mAutoResize(num_periods == 0), : mAutoResize(num_periods == 0),
mCurPeriod(0), mCurPeriod(0),
mNumPeriods(0), mNumRecordedPeriods(0),
mRecordingPeriods(num_periods ? num_periods : 1) mRecordingPeriods(num_periods ? num_periods : 1)
{ {
setPlayState(state); setPlayState(state);
...@@ -555,7 +555,7 @@ void PeriodicRecording::nextPeriod() ...@@ -555,7 +555,7 @@ void PeriodicRecording::nextPeriod()
mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size();
old_recording.splitTo(getCurRecording()); old_recording.splitTo(getCurRecording());
mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + 1); mNumRecordedPeriods = llmin((S32)mRecordingPeriods.size() - 1, mNumRecordedPeriods + 1);
} }
void PeriodicRecording::appendRecording(Recording& recording) void PeriodicRecording::appendRecording(Recording& recording)
...@@ -575,7 +575,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) ...@@ -575,7 +575,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
const S32 other_recording_slots = other.mRecordingPeriods.size(); const S32 other_recording_slots = other.mRecordingPeriods.size();
const S32 other_num_recordings = other.getNumRecordedPeriods(); const S32 other_num_recordings = other.getNumRecordedPeriods();
const S32 other_current_recording_index = other.mCurPeriod; const S32 other_current_recording_index = other.mCurPeriod;
const S32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings + 1) % other_recording_slots; const S32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings) % other_recording_slots;
// append first recording into our current slot // append first recording into our current slot
getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]);
...@@ -600,7 +600,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) ...@@ -600,7 +600,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
} }
mCurPeriod = mRecordingPeriods.size() - 1; mCurPeriod = mRecordingPeriods.size() - 1;
mNumPeriods = mRecordingPeriods.size(); mNumRecordedPeriods = mRecordingPeriods.size() - 1;
} }
else else
{ {
...@@ -629,7 +629,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) ...@@ -629,7 +629,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other )
llassert(num_to_copy >= 1); llassert(num_to_copy >= 1);
// advance to last recording period copied, and make that our current period // advance to last recording period copied, and make that our current period
mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size(); mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size();
mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + num_to_copy - 1); mNumRecordedPeriods = llmin((S32)mRecordingPeriods.size() - 1, mNumRecordedPeriods + num_to_copy - 1);
} }
// end with fresh period, otherwise next appendPeriodicRecording() will merge the first // end with fresh period, otherwise next appendPeriodicRecording() will merge the first
...@@ -722,7 +722,7 @@ void PeriodicRecording::handleReset() ...@@ -722,7 +722,7 @@ void PeriodicRecording::handleReset()
} }
} }
mCurPeriod = 0; mCurPeriod = 0;
mNumPeriods = 0; mNumRecordedPeriods = 0;
getCurRecording().setPlayState(getPlayState()); getCurRecording().setPlayState(getPlayState());
} }
...@@ -733,8 +733,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) ...@@ -733,8 +733,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other)
F64 PeriodicRecording::getPeriodMin( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodMin( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
F64 min_val = std::numeric_limits<F64>::max(); F64 min_val = std::numeric_limits<F64>::max();
...@@ -755,8 +754,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType<EventAccumulator>& stat, S32 ...@@ -755,8 +754,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType<EventAccumulator>& stat, S32
F64 PeriodicRecording::getPeriodMax( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodMax( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
F64 max_val = std::numeric_limits<F64>::min(); F64 max_val = std::numeric_limits<F64>::min();
...@@ -778,8 +776,7 @@ F64 PeriodicRecording::getPeriodMax( const StatType<EventAccumulator>& stat, S32 ...@@ -778,8 +776,7 @@ F64 PeriodicRecording::getPeriodMax( const StatType<EventAccumulator>& stat, S32
// calculates means using aggregates per period // calculates means using aggregates per period
F64 PeriodicRecording::getPeriodMean( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodMean( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 mean = 0; F64 mean = 0;
S32 valid_period_count = 0; S32 valid_period_count = 0;
...@@ -802,8 +799,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType<EventAccumulator>& stat, S3 ...@@ -802,8 +799,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType<EventAccumulator>& stat, S3
F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<EventAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 period_mean = getPeriodMean(stat, num_periods); F64 period_mean = getPeriodMean(stat, num_periods);
F64 sum_of_squares = 0; F64 sum_of_squares = 0;
...@@ -827,8 +823,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<EventAccumulat ...@@ -827,8 +823,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<EventAccumulat
F64 PeriodicRecording::getPeriodMin( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodMin( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
F64 min_val = std::numeric_limits<F64>::max(); F64 min_val = std::numeric_limits<F64>::max();
...@@ -849,8 +844,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType<SampleAccumulator>& stat, S3 ...@@ -849,8 +844,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType<SampleAccumulator>& stat, S3
F64 PeriodicRecording::getPeriodMax(const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/) F64 PeriodicRecording::getPeriodMax(const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/)
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
F64 max_val = std::numeric_limits<F64>::min(); F64 max_val = std::numeric_limits<F64>::min();
...@@ -872,8 +866,7 @@ F64 PeriodicRecording::getPeriodMax(const StatType<SampleAccumulator>& stat, S32 ...@@ -872,8 +866,7 @@ F64 PeriodicRecording::getPeriodMax(const StatType<SampleAccumulator>& stat, S32
F64 PeriodicRecording::getPeriodMean( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodMean( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
S32 valid_period_count = 0; S32 valid_period_count = 0;
F64 mean = 0; F64 mean = 0;
...@@ -895,8 +888,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType<SampleAccumulator>& stat, S ...@@ -895,8 +888,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType<SampleAccumulator>& stat, S
F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<SampleAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 period_mean = getPeriodMean(stat, num_periods); F64 period_mean = getPeriodMean(stat, num_periods);
S32 valid_period_count = 0; S32 valid_period_count = 0;
...@@ -921,8 +913,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<SampleAccumula ...@@ -921,8 +913,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType<SampleAccumula
F64Kilobytes PeriodicRecording::getPeriodMin( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64Kilobytes PeriodicRecording::getPeriodMin( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64Kilobytes min_val(std::numeric_limits<F64>::max()); F64Kilobytes min_val(std::numeric_limits<F64>::max());
for (S32 i = 1; i <= num_periods; i++) for (S32 i = 1; i <= num_periods; i++)
...@@ -941,8 +932,7 @@ F64Kilobytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, S32 num_ ...@@ -941,8 +932,7 @@ F64Kilobytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, S32 num_
F64Kilobytes PeriodicRecording::getPeriodMax(const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/) F64Kilobytes PeriodicRecording::getPeriodMax(const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/)
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64Kilobytes max_val(0.0); F64Kilobytes max_val(0.0);
for (S32 i = 1; i <= num_periods; i++) for (S32 i = 1; i <= num_periods; i++)
...@@ -961,8 +951,7 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_ ...@@ -961,8 +951,7 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_
F64Kilobytes PeriodicRecording::getPeriodMean( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64Kilobytes PeriodicRecording::getPeriodMean( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64Kilobytes mean(0); F64Kilobytes mean(0);
...@@ -982,8 +971,7 @@ F64Kilobytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, S32 num ...@@ -982,8 +971,7 @@ F64Kilobytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, S32 num
F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ ) F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType<MemAccumulator>& stat, S32 num_periods /*= S32_MAX*/ )
{ {
S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64Kilobytes period_mean = getPeriodMean(stat, num_periods); F64Kilobytes period_mean = getPeriodMean(stat, num_periods);
S32 valid_period_count = 0; S32 valid_period_count = 0;
......
...@@ -334,7 +334,11 @@ namespace LLTrace ...@@ -334,7 +334,11 @@ namespace LLTrace
~PeriodicRecording(); ~PeriodicRecording();
void nextPeriod(); void nextPeriod();
S32 getNumRecordedPeriods() { return mNumPeriods; } S32 getNumRecordedPeriods()
{
// current period counts if not active
return mNumRecordedPeriods + (isStarted() ? 0 : 1);
}
F64Seconds getDuration() const; F64Seconds getDuration() const;
...@@ -351,8 +355,7 @@ namespace LLTrace ...@@ -351,8 +355,7 @@ namespace LLTrace
template <typename T> template <typename T>
S32 getSampleCount(const StatType<T>& stat, S32 num_periods = S32_MAX) S32 getSampleCount(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
S32 num_samples = 0; S32 num_samples = 0;
for (S32 i = 1; i <= num_periods; i++) for (S32 i = 1; i <= num_periods; i++)
...@@ -371,8 +374,7 @@ namespace LLTrace ...@@ -371,8 +374,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename T::value_t getPeriodMin(const StatType<T>& stat, S32 num_periods = S32_MAX) typename T::value_t getPeriodMin(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
typename T::value_t min_val(std::numeric_limits<typename T::value_t>::max()); typename T::value_t min_val(std::numeric_limits<typename T::value_t>::max());
...@@ -417,8 +419,7 @@ namespace LLTrace ...@@ -417,8 +419,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMinPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX) typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMinPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename 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++) for (S32 i = 1; i <= num_periods; i++)
...@@ -443,8 +444,7 @@ namespace LLTrace ...@@ -443,8 +444,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename T::value_t getPeriodMax(const StatType<T>& stat, S32 num_periods = S32_MAX) typename T::value_t getPeriodMax(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
bool has_value = false; bool has_value = false;
typename T::value_t max_val(std::numeric_limits<typename T::value_t>::min()); typename T::value_t max_val(std::numeric_limits<typename T::value_t>::min());
...@@ -489,8 +489,7 @@ namespace LLTrace ...@@ -489,8 +489,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMaxPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX) typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMaxPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 max_val = std::numeric_limits<F64>::min(); F64 max_val = std::numeric_limits<F64>::min();
for (S32 i = 1; i <= num_periods; i++) for (S32 i = 1; i <= num_periods; i++)
...@@ -515,8 +514,7 @@ namespace LLTrace ...@@ -515,8 +514,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMean(const StatType<T >& stat, S32 num_periods = S32_MAX) typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMean(const StatType<T >& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename RelatedTypes<typename T::value_t>::fractional_t mean(0); typename RelatedTypes<typename T::value_t>::fractional_t mean(0);
...@@ -558,8 +556,7 @@ namespace LLTrace ...@@ -558,8 +556,7 @@ namespace LLTrace
template <typename T> template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMeanPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX) typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMeanPerSec(const StatType<T>& stat, S32 num_periods = S32_MAX)
{ {
S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, getNumRecordedPeriods());
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename RelatedTypes<typename T::value_t>::fractional_t mean = 0; typename RelatedTypes<typename T::value_t>::fractional_t mean = 0;
...@@ -616,7 +613,7 @@ namespace LLTrace ...@@ -616,7 +613,7 @@ namespace LLTrace
std::vector<Recording> mRecordingPeriods; std::vector<Recording> mRecordingPeriods;
const bool mAutoResize; const bool mAutoResize;
S32 mCurPeriod; S32 mCurPeriod;
S32 mNumPeriods; S32 mNumRecordedPeriods;
}; };
PeriodicRecording& get_frame_recording(); PeriodicRecording& get_frame_recording();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment