protected override void OnProfilingFinished(BaseProfilerResult <IMyFaction> result)
        {
            // get online players per faction
            var onlineFactions = new Dictionary <string, int>();
            var onlinePlayers  = MySession.Static.Players.GetOnlinePlayers();

            foreach (var onlinePlayer in onlinePlayers)
            {
                var faction = MySession.Static.Factions.TryGetPlayerFaction(onlinePlayer.PlayerId());
                if (faction == null)
                {
                    continue;
                }

                onlineFactions.Increment(faction.Tag);
            }

            foreach (var(faction, entity) in result.GetTopEntities())
            {
                onlineFactions.TryGetValue(faction.Tag, out var onlinePlayerCount);
                onlinePlayerCount = Math.Max(1, onlinePlayerCount); // fix zero division
                var mainMs          = entity.MainThreadTime / result.TotalFrameCount;
                var mainMsPerMember = mainMs / onlinePlayerCount;

                TorchInfluxDbWriter
                .Measurement("profiler_factions")
                .Tag("faction_tag", faction.Tag)
                .Field("main_ms", mainMs)
                .Field("main_ms_per_member", mainMsPerMember)
                .Write();
            }
        }
 protected override void OnProfilingFinished(BaseProfilerResult <Type> result)
 {
     foreach (var(type, entry) in result.GetTopEntities(MaxDisplayCount))
     {
         TorchInfluxDbWriter
         .Measurement("profiler_block_types")
         .Tag("block_type", type.Name)
         .Field("main_ms", (float)entry.MainThreadTime / result.TotalFrameCount)
         .Write();
     }
 }
 protected override void OnProfilingFinished(BaseProfilerResult <MyCubeGrid> result)
 {
     foreach (var(grid, entity) in result.GetTopEntities(MaxDisplayCount))
     {
         TorchInfluxDbWriter
         .Measurement("profiler")
         .Tag("grid_name", GridToResultText(grid))
         .Field("main_ms", (float)entity.MainThreadTime / result.TotalFrameCount)
         .Write();
     }
 }
Exemple #4
0
 protected override void OnProfilingFinished(BaseProfilerResult <string> result)
 {
     foreach (var(name, entity) in result.GetTopEntities())
     {
         TorchInfluxDbWriter
         .Measurement("profiler_method_names")
         .Tag("method_name", name)
         .Field("ms", (float)entity.MainThreadTime / result.TotalFrameCount)
         .Write();
     }
 }
 protected override void OnProfilingFinished(BaseProfilerResult <string> result)
 {
     foreach (var(methodName, entry) in result.GetTopEntities())
     {
         var eventName = methodName.Split('#')[1];
         TorchInfluxDbWriter
         .Measurement("profiler_network_events")
         .Tag("site_name", eventName)
         .Field("main_ms", (float)entry.MainThreadTime / result.TotalFrameCount)
         .Write();
     }
 }
Exemple #6
0
        protected override void OnProfilingFinished(BaseProfilerResult <MyIdentity> result)
        {
            foreach (var(player, entity) in result.GetTopEntities(10))
            {
                var playerName = player.DisplayName;
                var steamId    = MySession.Static.Players.TryGetSteamId(player.IdentityId);
                playerName = _nameConflictSolver.GetSafeName(playerName, steamId);

                var mainMs = entity.MainThreadTime / result.TotalFrameCount;

                TorchInfluxDbWriter
                .Measurement("profiler_players")
                .Tag("player_name", playerName)
                .Field("main_ms", mainMs)
                .Write();
            }
        }
Exemple #7
0
        protected override void OnProfilingFinished(BaseProfilerResult <MySessionComponentBase> result)
        {
            foreach (var(comp, entity) in result.GetTopEntities())
            {
                var ms = (float)entity.MainThreadTime / result.TotalFrameCount;

                var type = comp.GetType();
                var name = _myConfig.MonitorSessionComponentNamespace
                    ? $"{type.Namespace}/{type.Name}"
                    : type.Name;

                TorchInfluxDbWriter
                .Measurement("profiler_game_loop_session_components")
                .Tag("comp_name", name)
                .Field("main_ms", ms)
                .Write();
            }
        }
Exemple #8
0
        public void Update(BaseProfilerResult <MyIdentity> profileResult)
        {
            Log.Trace("updating player lags...");

            var results = new List <EntitySource>();

            foreach (var(player, profilerEntry) in profileResult.GetTopEntities(20))
            {
                var mspf       = profilerEntry.MainThreadTime / profileResult.TotalFrameCount;
                var faction    = MySession.Static.Factions.TryGetPlayerFaction(player.IdentityId);
                var factionId  = faction?.FactionId ?? 0L;
                var factionTag = faction?.Tag ?? "<single>";
                var result     = new EntitySource(player.IdentityId, player.DisplayName, player.IdentityId, player.DisplayName, factionId, factionTag, mspf);
                results.Add(result);
            }

            _entityTracker.Update(results);
            Log.Trace("updated player lags");
        }
Exemple #9
0
        protected override void OnProfilingFinished(BaseProfilerResult <MyProgrammableBlock> result)
        {
            foreach (var(pb, entity) in result.GetTopEntities(MaxDisplayCount))
            {
                var grid = pb?.GetParentEntityOfType <MyCubeGrid>();
                if (grid == null)
                {
                    return;
                }

                var gridName = _nameConflictSolver.GetSafeName(grid.DisplayName, grid.EntityId);
                var mainMs   = (float)entity.MainThreadTime / result.TotalFrameCount;

                TorchInfluxDbWriter
                .Measurement("profiler_scripts")
                .Tag("grid_name", gridName)
                .Field("main_ms", mainMs)
                .Write();
            }
        }
Exemple #10
0
        void ProcessResult(BaseProfilerResult <HkWorld> result)
        {
            foreach (var(world, entity) in result.GetTopEntities(_physicsConfig.PhysicsMaxClusterCount))
            {
                // this usually doesn't happen but just in case
                if (!TryGetHeaviestGrid(world, out var heaviestGrid))
                {
                    continue;
                }

                heaviestGrid.BigOwners.TryGetFirst(out var ownerId);
                var faction    = MySession.Static.Factions.GetPlayerFaction(ownerId);
                var factionTag = faction?.Tag ?? "<n/a>";
                var gridName   = heaviestGrid.DisplayName.OrNull() ?? "<no name>";
                var mainMs     = entity.MainThreadTime / result.TotalFrameCount;

                TorchInfluxDbWriter
                .Measurement("profiler_physics_grids")
                .Tag("grid", $"[{factionTag}] {gridName}")
                .Field("main_ms", mainMs)
                .Write();
            }
        }