Created
April 8, 2019 07:48
-
-
Save jkoenen/b7b1630c1c7dc117b1f8b35b2ad0daf1 to your computer and use it in GitHub Desktop.
ToolUi Memory Allocator View
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "holistic_memory_tracker_view.hpp" | |
| #include "keen/toolui/tui.hpp" | |
| #include "keen/toolui/tui_widget.hpp" | |
| #include "keen/base/pod_set.hpp" | |
| #include "keen/base/memory_tracker.hpp" | |
| #include "keen/dataschema/ds_type_collection.hpp" | |
| namespace keen | |
| { | |
| #if KEEN_USING( KEEN_MEMORY_TRACKER ) | |
| static void numberLabel( TuiContext* pContext, StringView string ) | |
| { | |
| TuiLabel label( pContext, string, TuiLabelParameter::create( UiAlignment::rightCenter() ) ); | |
| } | |
| #endif | |
| void holistic::doMemoryTrackerViewUi( TuiContext* pContext ) | |
| { | |
| TuiVerticalLayout verticalLayout( pContext ); | |
| verticalLayout.setStretch( 1.0f, 1.0f ); | |
| #if KEEN_USING( KEEN_MEMORY_TRACKER ) | |
| TlsDynamicArray<MemoryAllocatorInfo,128u> allocatorInfos; | |
| debug::fillAllocatorInfos( &allocatorInfos ); | |
| static const TuiTableColumnParameters s_tableColumns[] = | |
| { | |
| { "Name", 300.0f }, | |
| { "Pool Count", 100.0f }, | |
| { "Total Size", 100.0f }, | |
| { "Allocated Size", 100.0f }, | |
| { "Peak Size", 100.0f }, | |
| { "Allocation Count", 100.0f }, | |
| { "Peak Count", 100.0f }, | |
| { "Allocation Calls", 100.0f }, | |
| { "Fallback Size", 100.0f }, | |
| }; | |
| TuiTable table( pContext, s_tableColumns ); | |
| table.setStretch( 1.0f, 1.0f ); | |
| TuiTableListViewParameter parameter; | |
| parameter.totalElementCount = allocatorInfos.getSize(); | |
| TuiTableListView rowListView( &table, parameter ); | |
| for( size_t i = rowListView.getStartElementIndex(); i < rowListView.getEndElementIndex(); i = rowListView.getNextElementIndex( i ) ) | |
| { | |
| rowListView.newElement( (TuiObjectId)allocatorInfos[ i ].handle.getValue(), TuiListSelectState_Unselected ); | |
| rowListView.column(); tui::label( pContext, allocatorInfos[ i ].name ); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].poolCount )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].totalSize )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].allocatedSize )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].maxAllocatedSize )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].allocationCount )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].maxAllocationCount )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].totalAllocationCount )); | |
| rowListView.column(); numberLabel( pContext, tui::formatString( pContext, "%,d", allocatorInfos[ i ].fallbackAllocationSize ) ); | |
| } | |
| #else | |
| tui::label( pContext, "The Memory Tracker is not enabled!" ); | |
| #endif | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef KEEN_HOLISTIC_MEMORY_TRACKER_VIEW_HPP | |
| #define KEEN_HOLISTIC_MEMORY_TRACKER_VIEW_HPP | |
| namespace keen | |
| { | |
| struct TuiContext; | |
| namespace holistic | |
| { | |
| void doMemoryTrackerViewUi( TuiContext* pContext ); | |
| } | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment