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

Function fxCreateProfiler

xs/sources/xsDebug.c:3280–3304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3278}
3279
3280void fxCreateProfiler(txMachine* the)
3281{
3282 txProfiler* profiler = the->profiler = c_malloc(sizeof(txProfiler));
3283 if (profiler == C_NULL)
3284 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
3285 profiler->interval = 1250;
3286 profiler->former = fxGetMicroSeconds();
3287 profiler->when = profiler->former + profiler->interval;
3288
3289 profiler->recordCount = 128;
3290 profiler->records = c_calloc(1, profiler->recordCount);
3291 if (profiler->records == C_NULL)
3292 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
3293
3294 profiler->sampleIndex = 0;
3295 profiler->sampleSize = (the->stackTop - the->stackBottom) >> 3;
3296 profiler->samples = (txID*)c_malloc((size_t)(mxProfilerSampleCount * profiler->sampleSize * sizeof(txID)));
3297 if (profiler->samples == C_NULL)
3298 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
3299
3300 fxSendProfilerTime(the, "start", profiler->former);
3301 fxSendProfilerRecord(the, C_NULL, 0, C_NULL);
3302 fxSendProfilerRecord(the, C_NULL, 1, C_NULL);
3303 profiler->records[0] = 0x03;
3304}
3305
3306void fxDeleteProfiler(txMachine* the, void* stream)
3307{

Callers 1

fxStartProfilingFunction · 0.70

Calls 4

fxGetMicroSecondsFunction · 0.85
fxSendProfilerTimeFunction · 0.85
fxSendProfilerRecordFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected