Vue.component('app-overview', { mounted: function() { this.startRequesting(""); }, beforeDestroy: function() { this.stopRequesting(); }, data: function() { return { data: {}, data_request: undefined, error: false, tick: 0 } }, methods: { request_data() { var url = "metrics?world=yes"; this.tick ++; app.get(url, (msg) => { this.data = msg; this.error = false; }, (Http) => { if (Http.status == 404) { this.error = true; } }); }, // Stop periodically requesting the scope stopRequesting() { this.data = []; clearInterval(this.data_request); }, // Start periodically requesting a scope startRequesting(scope) { this.stopRequesting(); // Initial request this.request_data(); // Start periodic request this.data_request = window.setInterval(function() { this.request_data(); }.bind(this), 1000); }, entity_count() { if (!this.data.world) { return 0; } return this.data.world.current.entity_count; }, operation_count() { if (!this.data.world) { return 0; } return (this.data.world.current.add_count + this.data.world.current.remove_count + this.data.world.current.clear_count + this.data.world.current.delete_count + this.data.world.current.set_count + this.data.world.current.bulk_new_count).toFixed(0); }, system_count() { if (!this.data.world) { return 0; } return (this.data.world.current.systems_ran).toFixed(0); }, component_count() { if (!this.data.world) { return 0; } return this.data.world.current.component_count; }, table_count() { if (!this.data.world) { return 0; } return this.data.world.current.table_count; }, fragmentation() { if (!this.data.world) { return 0; } /* Compute global fragmentation as total matched tables divided by total * matched entities. Subtract one from the tables, so that if there is a * single entity matching a single table, fragmentation is 0% */ return (100 * (this.data.world.current.matched_table_count - 1) / this.data.world.current.matched_entity_count).toFixed(0); } }, template: `
entities
{{entity_count()}}
components
{{component_count()}}
systems
{{system_count()}}
tables
{{table_count()}}
fragmentation
{{fragmentation()}}%
performance
delta time
operations ({{operation_count()}})
entities ({{entity_count()}})
tables ({{table_count()}})
` }); app.app_loaded("overview", [{ name: "entity-graph", url: "apps/overview/entity_graph.js" }, { name: "performance-graph", url: "apps/overview/performance_graph.js" }, { name: "operation-graph", url: "apps/overview/operation_graph.js" }, { name: "table-graph", url: "apps/overview/table_graph.js" }, { name: "delta-time-graph", url: "apps/overview/delta_time_graph.js" }]);