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

Function fxCheckProfiler

xs/sources/xsDebug.c:3244–3278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3242static void fxSendProfilerTime(txMachine* the, txString name, txMicroseconds when);
3243
3244void fxCheckProfiler(txMachine* the, txSlot* frame)
3245{
3246 txProfiler* profiler = the->profiler;
3247 if (!profiler)
3248 return;
3249 txMicroseconds when = profiler->when;
3250 txMicroseconds time = fxGetMicroSeconds();
3251 if (when <= time) {
3252 txSize sampleIndex = profiler->sampleIndex;
3253 txSize sampleSize = profiler->sampleSize;
3254 txID* samples = profiler->samples + (sampleIndex * sampleSize);
3255 txU4 interval = profiler->interval;
3256 profiler->deltas[sampleIndex] = (txU4)(time - profiler->former);
3257 profiler->former = time;
3258 profiler->when = time + interval - (time % interval);
3259 if (!frame) {
3260 frame = the->frame;
3261 if (frame)
3262 *samples++ = 1;
3263 }
3264 while (frame) {
3265 txID id = fxFrameToProfilerID(the, frame);
3266 if (id)
3267 *samples++ = id;
3268 frame = frame->next;
3269 }
3270 *samples++ = 0;
3271 sampleIndex++;
3272 if (sampleIndex == mxProfilerSampleCount) {
3273 fxSendProfilerSamples(the, profiler);
3274 sampleIndex = 0;
3275 }
3276 profiler->sampleIndex = sampleIndex;
3277 }
3278}
3279
3280void fxCreateProfiler(txMachine* the)
3281{

Callers 4

fxRunIDFunction · 0.70
xsRun.cFile · 0.70
fxCollectFunction · 0.70
fxBeginHostFunction · 0.70

Calls 3

fxGetMicroSecondsFunction · 0.85
fxFrameToProfilerIDFunction · 0.85
fxSendProfilerSamplesFunction · 0.85

Tested by

no test coverage detected