"luastats" command
This commit is contained in:
parent
b498386673
commit
84c1b04de6
|
@ -23,6 +23,7 @@ static char luaUserHeap[LUA_USER_HEAP];
|
||||||
static char luaSystemHeap[LUA_SYSTEM_HEAP];
|
static char luaSystemHeap[LUA_SYSTEM_HEAP];
|
||||||
|
|
||||||
class Heap {
|
class Heap {
|
||||||
|
public:
|
||||||
memory_heap_t m_heap;
|
memory_heap_t m_heap;
|
||||||
|
|
||||||
size_t m_memoryUsed = 0;
|
size_t m_memoryUsed = 0;
|
||||||
|
@ -208,6 +209,16 @@ static LuaHandle systemLua;
|
||||||
|
|
||||||
const char* getSystemLuaScript();
|
const char* getSystemLuaScript();
|
||||||
|
|
||||||
|
static void printStats() {
|
||||||
|
#if !EFI_UNIT_TEST
|
||||||
|
size_t freeRam;
|
||||||
|
chHeapStatus(&heaps[0].m_heap, &freeRam, nullptr);
|
||||||
|
efiPrintf("User free %d of %d", freeRam, sizeof(luaUserHeap));
|
||||||
|
chHeapStatus(&heaps[1].m_heap, &freeRam, nullptr);
|
||||||
|
efiPrintf("System free %d of %d", freeRam, sizeof(luaSystemHeap));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void initSystemLua() {
|
void initSystemLua() {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, !systemLua, "system lua already init");
|
efiAssertVoid(OBD_PCM_Processor_Fault, !systemLua, "system lua already init");
|
||||||
|
|
||||||
|
@ -225,6 +236,7 @@ void initSystemLua() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto startTime = startTimer.getElapsedSeconds();
|
auto startTime = startTimer.getElapsedSeconds();
|
||||||
|
addConsoleAction("luastats", printStats);
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
efiPrintf("System Lua loaded in %.2f ms using %d bytes", startTime * 1'000, heaps[1].used());
|
efiPrintf("System Lua loaded in %.2f ms using %d bytes", startTime * 1'000, heaps[1].used());
|
||||||
|
|
Loading…
Reference in New Issue