MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxCheckProfiler

Function fxCheckProfiler

xs/sources/xsProfile.c:108–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106static txU8 fxTicksToMicroseconds(txU8 ticks);
107
108void fxCheckProfiler(txMachine* the, txSlot* frame)
109{
110 txProfiler* profiler = the->profiler;
111 if (!profiler)
112 return;
113 txU8 when = profiler->when;
114 txU8 time = fxGetTicks();
115 if (when < time) {
116 txProfilerRecord* callee = C_NULL;
117 txProfilerRecord* record = C_NULL;
118 if (frame) {
119 record = fxFrameToProfilerRecord(the, frame);
120 frame = frame->next;
121 }
122 else {
123 frame = the->frame;
124 if (frame)
125 record = profiler->gc;
126 }
127 if (record) {
128 callee = record;
129 while (frame) {
130 txProfilerRecord* parent = fxFrameToProfilerRecord(the, frame);
131 if (parent) {
132 fxInsertProfilerCallee(the, parent, callee->recordID);
133 callee = parent;
134 }
135 frame = frame->next;
136 }
137 }
138 if (callee)
139 fxInsertProfilerCallee(the, profiler->host, callee->recordID);
140 else
141 record = profiler->host;
142 txU4 interval = profiler->interval;
143 record->hitCount++;
144#ifdef mxMetering
145 fxPushProfilerSample(the, record->recordID, (txU4)(time - profiler->former), (txU4)(the->meterIndex - profiler->formerMeter));
146 profiler->formerMeter = the->meterIndex;
147#else
148 fxPushProfilerSample(the, record->recordID, (txU4)(time - profiler->former));
149#endif
150 profiler->former = time;
151 profiler->when = time + interval - (time % interval);
152 }
153}
154
155void fxCreateProfiler(txMachine* the)
156{

Callers

nothing calls this directly

Calls 4

fxGetTicksFunction · 0.85
fxFrameToProfilerRecordFunction · 0.85
fxInsertProfilerCalleeFunction · 0.85
fxPushProfilerSampleFunction · 0.85

Tested by

no test coverage detected