-
Notifications
You must be signed in to change notification settings - Fork 855
Ensure DebugFrameTiming doesn't allocate #6368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,11 @@ internal FrameTimeSample(float initValue) | |
/// </summary> | ||
class FrameTimeSampleHistory | ||
{ | ||
public FrameTimeSampleHistory(int initialCapacity) | ||
{ | ||
m_Samples.Capacity = initialCapacity; | ||
} | ||
|
||
List<FrameTimeSample> m_Samples = new(); | ||
|
||
internal FrameTimeSample SampleAverage; | ||
|
@@ -112,8 +117,12 @@ void ForEachSampleMember(ref FrameTimeSample aggregate, FrameTimeSample sample, | |
|
||
internal void DiscardOldSamples(int sampleHistorySize) | ||
{ | ||
Debug.Assert(sampleHistorySize > 0, "Invalid sampleHistorySize"); | ||
|
||
while (m_Samples.Count >= sampleHistorySize) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would check the sampleHistorySize to have a correct value. As I might call it with -1 and get an infinte loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I fixed this one right away. |
||
m_Samples.RemoveAt(0); | ||
|
||
m_Samples.Capacity = sampleHistorySize; | ||
} | ||
|
||
internal void Clear() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that
BottleneckHistory
andFrameTimeSampleHistory
are pretty the same. I would encourage you to do a base generic class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had the same thought when making the same changes to both files, but decided to not tackle the issue right now :) I do agree this would make sense though. I'll make a note to come back to this later.