MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Extract

Method Extract

Source/Engine/Profiler/ProfilerCPU.cpp:28–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void ProfilerCPU::EventBuffer::Extract(Array<Event>& data, bool withRemoval)
29{
30 data.Clear();
31
32 // Peek ring buffer state
33 int32 count = _count;
34 const int32 capacity = _capacity;
35
36 // Skip if empty
37 if (count == 0)
38 return;
39
40 // Fix iterators when buffer is full (begin == end)
41 if (count == capacity)
42 {
43 _count--;
44 count--;
45 }
46
47 // Find the first item (skip non-root events)
48 Iterator firstEvent = Begin();
49 for (auto i = firstEvent; i.IsNotEnd(); ++i)
50 {
51 if (i.Event().Depth == 0)
52 {
53 firstEvent = i;
54 break;
55 }
56 }
57
58 // Skip if no root event found inside the buffer
59 if (firstEvent.IsEnd())
60 return;
61
62 // Find the last item (last event in ended root event)
63 Iterator lastEndedRoot = End();
64 for (auto i = Last(); i != firstEvent; --i)
65 {
66 if (i.Event().Depth == 0 && i.Event().End > 0)
67 {
68 lastEndedRoot = i;
69 break;
70 }
71 }
72
73 // Skip if no finished root event found inside the buffer
74 if (lastEndedRoot.IsEnd())
75 return;
76
77 // Find the last non-root event in last root event
78 Iterator lastEvent = lastEndedRoot;
79 const double lastRootEventEndTime = lastEndedRoot.Event().End;
80 for (auto i = --End(); i != lastEndedRoot; --i)
81 {
82 if (i.Event().End > 0 && i.Event().End <= lastRootEventEndTime)
83 {
84 lastEvent = i;
85 break;

Callers 1

UpdateMethod · 0.45

Calls 10

EventMethod · 0.80
BeginFunction · 0.50
EndFunction · 0.50
MinFunction · 0.50
ClearMethod · 0.45
IsNotEndMethod · 0.45
IsEndMethod · 0.45
IndexMethod · 0.45
ResizeMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected