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

Function fxCreateProfiler

xs/sources/xsProfile.c:155–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void fxCreateProfiler(txMachine* the)
156{
157 txProfiler* profiler = the->profiler = c_malloc(sizeof(txProfiler));
158 if (profiler == C_NULL)
159 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
160 profiler->interval = (txU4)fxMicrosecondsToTicks(1250);
161 profiler->former = fxGetTicks();
162 profiler->when = profiler->former + profiler->interval;
163 profiler->start = profiler->former;
164#ifdef mxMetering
165 profiler->interval >>= 1;
166 profiler->formerMeter = the->meterIndex;
167 profiler->startMeter = profiler->formerMeter;
168#endif
169 profiler->recordCount = 2;
170 profiler->records = (txProfilerRecord**)c_calloc(sizeof(txProfilerRecord*), profiler->recordCount);
171 if (profiler->records == C_NULL)
172 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
173
174 profiler->sampleCount = 1024;
175 profiler->sampleIndex = 0;
176 profiler->samples = (txProfilerSample*)c_malloc((size_t)(profiler->sampleCount * sizeof(txProfilerSample)));
177 if (profiler->samples == C_NULL)
178 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
179 profiler->host = fxNewProfilerRecord(the, 0);
180 profiler->gc = fxNewProfilerRecord(the, 1);
181}
182
183void fxDeleteProfiler(txMachine* the, void* stream)
184{

Callers

nothing calls this directly

Calls 4

fxMicrosecondsToTicksFunction · 0.85
fxGetTicksFunction · 0.85
fxNewProfilerRecordFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected