Skip to content

Commit 1ce7bff

Browse files
committed
Add page for tables and queries
1 parent 26eb2d5 commit 1ce7bff

File tree

18 files changed

+1290
-247
lines changed

18 files changed

+1290
-247
lines changed

deps/flecs.c

Lines changed: 156 additions & 121 deletions
Large diffs are not rendered by default.

deps/flecs.h

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4289,7 +4289,6 @@ typedef struct {
42894289
ecs_compare_action_t compare;
42904290
ecs_size_t key_size;
42914291
ecs_size_t value_size;
4292-
ecs_block_allocator_t *hashmap_allocator;
42934292
ecs_map_t impl;
42944293
} ecs_hashmap_t;
42954294

@@ -13706,6 +13705,15 @@ FLECS_API
1370613705
ecs_entities_memory_t ecs_entity_memory_get(
1370713706
const ecs_world_t *world);
1370813707

13708+
/** Get memory usage statistics for single component record.
13709+
*
13710+
* @param cr The component record.
13711+
* @param result Memory statistics for component record (out).
13712+
*/
13713+
void ecs_component_record_memory_get(
13714+
const ecs_component_record_t *cr,
13715+
ecs_component_index_memory_t *result);
13716+
1370913717
/** Get memory usage statistics for the component index.
1371013718
*
1371113719
* @param world The world.
@@ -13721,9 +13729,18 @@ ecs_component_index_memory_t ecs_component_index_memory_get(
1372113729
* @return Memory statistics for queries.
1372213730
*/
1372313731
FLECS_API
13724-
ecs_query_memory_t ecs_query_memory_get(
13732+
ecs_query_memory_t ecs_queries_memory_get(
1372513733
const ecs_world_t *world);
1372613734

13735+
/** Get component memory for table.
13736+
*
13737+
* @param table The table.
13738+
* @param result The memory used by components stored in this table (out).
13739+
*/
13740+
void ecs_table_component_memory_get(
13741+
const ecs_table_t *table,
13742+
ecs_component_memory_t *result);
13743+
1372713744
/** Get memory usage statistics for components.
1372813745
*
1372913746
* @param world The world.
@@ -13733,13 +13750,23 @@ FLECS_API
1373313750
ecs_component_memory_t ecs_component_memory_get(
1373413751
const ecs_world_t *world);
1373513752

13753+
/** Get memory usage statistics for single table.
13754+
*
13755+
* @param world The world.
13756+
* @param table The table.
13757+
* @param result Memory statistics for table (out).
13758+
*/
13759+
void ecs_table_memory_get(
13760+
const ecs_table_t *table,
13761+
ecs_table_memory_t *result);
13762+
1373613763
/** Get memory usage statistics for tables.
1373713764
*
1373813765
* @param world The world.
1373913766
* @return Memory statistics for tables.
1374013767
*/
1374113768
FLECS_API
13742-
ecs_table_memory_t ecs_table_memory_get(
13769+
ecs_table_memory_t ecs_tables_memory_get(
1374313770
const ecs_world_t *world);
1374413771

1374513772
/** Get number of tables by number of entities in the table.

etc/flecs_explorer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etc/flecs_explorer.wasm

2.51 KB
Binary file not shown.

etc/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<body spellcheck="false">
1414
<div id="app">
1515
<menu-bar
16-
:items="['entities', 'queries', 'stats', 'commands', 'info', 'docs']">
16+
:items="['entities', 'queries', 'stats', 'commands', 'internals', 'info', 'docs']">
1717
<template v-slot:docs>
1818
<menu-button
1919
name="docs"
@@ -49,10 +49,10 @@
4949
v-model:page="app_params.page">
5050
</menu-button>
5151
</template>
52-
<template v-slot:info>
52+
<template v-slot:internals>
5353
<menu-button
54-
name="info"
55-
img="info"
54+
name="internals"
55+
img="chip"
5656
v-model:page="app_params.page">
5757
</menu-button>
5858
</template>
@@ -90,6 +90,14 @@
9090
</page-commands>
9191
</template>
9292

93+
<template v-if="app_params.page == 'internals'">
94+
<page-internals
95+
:conn="conn"
96+
v-model:app_params="app_params"
97+
:app_state="app_state">
98+
</page-internals>
99+
</template>
100+
93101
<template v-if="app_params.page == 'info'">
94102
<page-info
95103
:conn="conn"

etc/js/app.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const defaultAppParams = {
3131
inspector_tab: "Inspect",
3232
tree_mode: "Entities",
3333
},
34+
internals: {
35+
tab: "tables",
36+
},
3437
sidebar: true,
3538
pipeline: "All systems",
3639
scripts: [],
@@ -159,6 +162,7 @@ let components = [
159162
loadModule('js/components/widgets/edit-tabs.vue', options),
160163
loadModule('js/components/widgets/edit-tabs-close-button.vue', options),
161164
loadModule('js/components/widgets/histogram.vue', options),
165+
loadModule('js/components/widgets/data-table.vue', options),
162166
loadModule('js/components/icon.vue', options),
163167
loadModule('js/components/toggle.vue', options),
164168
loadModule('js/components/search-box.vue', options),
@@ -253,9 +257,13 @@ let components = [
253257
loadModule('js/components/pages/commands/inspect-cmd-history.vue', options),
254258
loadModule('js/components/pages/commands/inspect-cmd.vue', options),
255259

256-
// Info page
257-
loadModule('js/components/pages/info/page.vue', options),
258-
loadModule('js/components/pages/info/pane-info.vue', options),
260+
// Internals page
261+
loadModule('js/components/pages/internals/page.vue', options),
262+
loadModule('js/components/pages/internals/tables.vue', options),
263+
loadModule('js/components/pages/internals/components.vue', options),
264+
loadModule('js/components/pages/internals/build.vue', options),
265+
loadModule('js/components/pages/internals/connection.vue', options),
266+
loadModule('js/components/pages/internals/natvis.vue', options),
259267
];
260268

261269
Promise.all(components).then((values) => {

etc/js/common.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,63 @@ explorer = {
88
}
99
},
1010

11+
shortenComponent: function(component) {
12+
let result;
13+
if (component[0] !== "(") {
14+
// Not a pair
15+
result = this.shortenEntity(component);
16+
} else {
17+
let pair = component.slice(1, -1).split(",");
18+
let rel = this.shortenEntity(pair[0]);
19+
result = "(" + this.shortenEntity(pair[0]) + ", " + pair[1] + ")";
20+
}
21+
return result;
22+
},
23+
1124
entityParent: function(path) {
1225
path = path.replaceAll("\\\.", "@@");
1326
const names = path.split(".");
1427
names.pop();
1528
return names.join(".").replaceAll("@@", ".");
1629
},
1730

31+
calculateMemoryTotal: function(data) {
32+
let result = 0;
33+
for (let key in data) {
34+
if (Array.isArray(data[key])) {
35+
return data[key];
36+
}
37+
if (key.startsWith('bytes_')) {
38+
result += data[key];
39+
}
40+
}
41+
return result;
42+
},
43+
44+
fmtSize: function(size) {
45+
if (typeof size === 'string') {
46+
size = parseInt(size);
47+
}
48+
49+
if (typeof size !== 'number') {
50+
return "n/a";
51+
}
52+
53+
if (size === 0) {
54+
return "0 B";
55+
}
56+
const k = 1024;
57+
const sizes = ['B', 'KB', 'MB', 'GB'];
58+
59+
let i = 0;
60+
while (size > 1000) {
61+
size /= 1000;
62+
i ++;
63+
}
64+
65+
return size.toFixed(2) + ' ' + sizes[i];
66+
},
67+
1868
fmtDuration: function(seconds) {
1969
let result = "";
2070

etc/js/components/pages/entities/entities-overview.vue

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,6 @@ function categoryLabel(name) {
266266
return result;
267267
}
268268
269-
function calculateTotal(data) {
270-
let result = 0;
271-
for (let key in data) {
272-
if (Array.isArray(data[key])) {
273-
return data[key];
274-
}
275-
if (key.startsWith('bytes_')) {
276-
result += data[key];
277-
}
278-
}
279-
return result;
280-
}
281-
282269
const chartData = computed(() => {
283270
if (!hasMemoryData.value) return [];
284271
const stats = memoryStats.value;
@@ -287,7 +274,7 @@ const chartData = computed(() => {
287274
288275
let i = 0;
289276
for (let key in stats) {
290-
const total = calculateTotal(stats[key]);
277+
const total = explorer.calculateMemoryTotal(stats[key]);
291278
if (Array.isArray(total)) {
292279
continue;
293280
}
@@ -311,7 +298,7 @@ const memoryData = computed(() => {
311298
312299
let i = 0;
313300
for (let key in stats) {
314-
const total = calculateTotal(stats[key]);
301+
const total = explorer.calculateMemoryTotal(stats[key]);
315302
const hideTitle = Array.isArray(total);
316303
317304
result.push({

etc/js/components/pages/info/page.vue

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)