private static bool RoundTimeTooShortForMeasuring(StatisticsNode statistics) { float startRoundTimeInSec = statistics.performanceStatisticsHelper.startRoundTimeInSec; int delayInSecBeforeMeasuringStarted = statistics.performanceStatisticsSettings.DelayInSecBeforeMeasuringStarted; return((UnityTime.realtimeSinceStartup - startRoundTimeInSec) < delayInSecBeforeMeasuringStarted); }
public static void PrepareTreeViewForStatisticsDisplay(NodeView view) { view.AppendColumn("Description", new Gtk.CellRendererText(), delegate(TreeViewColumn column, CellRenderer cell, ITreeNode treeNode) { StatisticsNode node = (StatisticsNode)treeNode; ((CellRendererText)cell).Text = node.Description; }); view.AppendColumn("Object count", new Gtk.CellRendererText(), delegate(TreeViewColumn column, CellRenderer cell, ITreeNode treeNode) { StatisticsNode node = (StatisticsNode)treeNode; ((CellRendererText)cell).Text = node.ItemsCount.ToString(); }); view.AppendColumn("Allocated bytes", new Gtk.CellRendererText(), delegate(TreeViewColumn column, CellRenderer cell, ITreeNode treeNode) { StatisticsNode node = (StatisticsNode)treeNode; ((CellRendererText)cell).Text = node.AllocatedBytes.ToString(); }); view.NodeStore = new Gtk.NodeStore(typeof(StatisticsNode)); }
void FillStatisticsListWithClassData() { currentListMenuHandler = listMenuHandlerForClasses; if (currentSelection != null) { if (currentSelection.Items != null) { FillTreeViewWithStatistics(PerClassStatistics, currentSelection.Items.ClassStatistics); } else { PerClassStatistics.NodeStore.Clear(); } } currentListSelection = null; }
void FillStatisticsListWithCallStackData() { currentListMenuHandler = listMenuHandlerForCallStacks; if (currentSelection != null) { if (currentSelection.Items != null) { if (!currentSelection.Items.ObjectAllocationsArePresent) { currentSelection.Items.FindObjectAllocations(currentSelection.Root); } FillTreeViewWithStatistics(PerClassStatistics, currentSelection.Items.AllocationCallStackStatistics); } else { PerClassStatistics.NodeStore.Clear(); } } currentListSelection = null; }
public HeapSnapshotExplorer() { Build(); MenuItem menuItem; OnClearMark(); loadHeapSnapshotBlock = new Menu(); menuItem = new MenuItem("Load block data"); menuItem.Activated += delegate { OnLoadHeapSnapshotData(); }; loadHeapSnapshotBlock.Append(menuItem); loadAllocationsBlocks = new Menu(); menuItem = new MenuItem("Load block data"); menuItem.Activated += delegate { OnLoadAllocationsEventData(); }; loadAllocationsBlocks.Append(menuItem); filterObjectSet = new Menu(); menuItem = new MenuItem("Filter by object class"); menuItem.Activated += delegate { OnFilterByClass <HeapObject> (); }; filterObjectSet.Append(menuItem); menuItem = new MenuItem("Filter by \"references object of class\""); menuItem.Activated += delegate { OnFilterByReferencesObjectOfClass(); }; filterObjectSet.Append(menuItem); menuItem = new MenuItem("Filter by \"is referenced by object of class\""); menuItem.Activated += delegate { OnFilterByIsReferencedByObjectOfClass(); }; filterObjectSet.Append(menuItem); menuItem = new MenuItem("Mark set for comparison"); menuItem.Activated += delegate { OnMarkObjectSetForComparison(); }; filterObjectSet.Append(menuItem); menuItem = new MenuItem("Mark set for \"set reference\" filtering"); menuItem.Activated += delegate { OnMarkObjectSetForFiltering(); }; filterObjectSet.Append(menuItem); filterAllocationSet = new Menu(); menuItem = new MenuItem("Filter by object class"); menuItem.Activated += delegate { OnFilterByClass <AllocatedObject> (); }; filterAllocationSet.Append(menuItem); menuItem = new MenuItem("Mark set for comparison"); menuItem.Activated += delegate { OnMarkAllocationSetForComparison(); }; filterAllocationSet.Append(menuItem); // For now no set based filtering for allocations... //menuItem = new MenuItem ("Mark set for filtering"); //menuItem.Activated += delegate { // OnMarkAllocationSetForFiltering (); //}; //filterAllocationSet.Append (menuItem); compareObjectSet = new Menu(); menuItem = new MenuItem("Perform comparison with this set"); menuItem.Activated += delegate { OnCompareWithSet <HeapObject> (); }; compareObjectSet.Append(menuItem); menuItem = new MenuItem("Perform intersection with this set"); menuItem.Activated += delegate { OnIntersectWithSet <HeapObject> (); }; compareObjectSet.Append(menuItem); menuItem = new MenuItem("Clear selection"); menuItem.Activated += delegate { OnClearMark(); }; compareObjectSet.Append(menuItem); compareAllocationSet = new Menu(); menuItem = new MenuItem("Perform comparison with this set"); menuItem.Activated += delegate { OnCompareWithSet <AllocatedObject> (); }; compareAllocationSet.Append(menuItem); menuItem = new MenuItem("Perform intersection with this set"); menuItem.Activated += delegate { OnIntersectWithSet <AllocatedObject> (); }; compareAllocationSet.Append(menuItem); menuItem = new MenuItem("Clear selection"); menuItem.Activated += delegate { OnClearMark(); }; compareAllocationSet.Append(menuItem); filterObjectSetUsingSelection = new Menu(); menuItem = new MenuItem("Select objects referencing objects in this set"); menuItem.Activated += delegate { OnFilterByReferencesObjectInSet <HeapObject> (); }; filterObjectSetUsingSelection.Append(menuItem); menuItem = new MenuItem("Select objects referenced by objects in this set"); menuItem.Activated += delegate { OnFilterByIsReferencedByObjectInSet <HeapObject> (); }; filterObjectSetUsingSelection.Append(menuItem); menuItem = new MenuItem("Clear selection"); menuItem.Activated += delegate { OnClearMark(); }; filterObjectSetUsingSelection.Append(menuItem); filterAllocationSetUsingSelection = new Menu(); menuItem = new MenuItem("Select objects referencing objects in this set"); menuItem.Activated += delegate { OnFilterByReferencesObjectInSet <AllocatedObject> (); }; filterAllocationSetUsingSelection.Append(menuItem); menuItem = new MenuItem("Select objects referenced by objects in this set"); menuItem.Activated += delegate { OnFilterByIsReferencedByObjectInSet <AllocatedObject> (); }; filterAllocationSetUsingSelection.Append(menuItem); menuItem = new MenuItem("Clear selection"); menuItem.Activated += delegate { OnClearMark(); }; filterAllocationSetUsingSelection.Append(menuItem); PrepareTreeViewForStatisticsDisplay(PerClassStatistics); PerClassStatistics.NodeSelection.Changed += delegate(object o, EventArgs args) { currentListSelection = (StatisticsNode)PerClassStatistics.NodeSelection.SelectedNode; }; listMenuHandlerForClasses = new StatisticsNodeMenuHandlerForClasses(this); listMenuHandlerForMethods = new StatisticsNodeMenuHandlerForMethods(this); listMenuHandlerForCallStacks = new StatisticsNodeMenuHandlerForCallStacks(this); Tree.Selection.Changed += delegate(object o, EventArgs args) { TreeSelection selection = (TreeSelection)o; TreeIter iter; if (selection.GetSelected(out iter)) { currentSelection = (HeapExplorerTreeModel.INode)Tree.Model.GetValue(iter, 0); FillStatisticsListWithClassData(); } }; Gtk.TreeViewColumn setColumn = new Gtk.TreeViewColumn(); Gtk.TreeViewColumn countColumn = new Gtk.TreeViewColumn(); Gtk.TreeViewColumn bytesColumn = new Gtk.TreeViewColumn(); setColumn.Title = "Object set"; countColumn.Title = "Object count"; bytesColumn.Title = "Bytes"; Gtk.CellRendererText setCell = new Gtk.CellRendererText(); Gtk.CellRendererText countCell = new Gtk.CellRendererText(); Gtk.CellRendererText bytesCell = new Gtk.CellRendererText(); setColumn.PackStart(setCell, true); countColumn.PackStart(countCell, true); bytesColumn.PackStart(bytesCell, true); setColumn.SetCellDataFunc(setCell, delegate(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { HeapExplorerTreeModel.INode node = (HeapExplorerTreeModel.INode)model.GetValue(iter, 0); CellRendererText textCell = (CellRendererText)cell; textCell.Text = node.Description; if (node != MarkedNode) { textCell.Style = Pango.Style.Normal; } else { textCell.Style = Pango.Style.Italic; } }); countColumn.SetCellDataFunc(countCell, delegate(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { HeapExplorerTreeModel.INode node = (HeapExplorerTreeModel.INode)model.GetValue(iter, 0); CellRendererText textCell = (CellRendererText)cell; textCell.Text = node.Count; if (node != MarkedNode) { textCell.Style = Pango.Style.Normal; } else { textCell.Style = Pango.Style.Italic; } }); bytesColumn.SetCellDataFunc(bytesCell, delegate(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { HeapExplorerTreeModel.INode node = (HeapExplorerTreeModel.INode)model.GetValue(iter, 0); CellRendererText textCell = (CellRendererText)cell; textCell.Text = node.AllocatedBytes; if (node != MarkedNode) { textCell.Style = Pango.Style.Normal; } else { textCell.Style = Pango.Style.Italic; } }); setColumn.AddAttribute(setCell, "text", 0); countColumn.AddAttribute(countCell, "text", 1); bytesColumn.AddAttribute(bytesCell, "text", 2); Tree.AppendColumn(setColumn); Tree.AppendColumn(countColumn); Tree.AppendColumn(bytesColumn); loadHeapSnapshotBlock.ShowAll(); loadAllocationsBlocks.ShowAll(); filterObjectSet.ShowAll(); filterAllocationSet.ShowAll(); compareObjectSet.ShowAll(); compareAllocationSet.ShowAll(); filterObjectSetUsingSelection.ShowAll(); filterAllocationSetUsingSelection.ShowAll(); }
public void SendStatisticDataOnRoundStop(NodeRemoveEvent e, SingleNode <RoundUserComponent> roundUser, [JoinByUser] BattleUserNode battleUser, [JoinByUser] SelfUserNode selfUser, [JoinByUser] SingleNode <RoundUserComponent> node, [JoinByBattle] SingleNode <BattleComponent> battle, [JoinByMap] SingleNode <MapComponent> map, [JoinAll] StatisticsNode statistics) { if (!RoundTimeTooShortForMeasuring(statistics)) { PerformanceStatisticsHelperComponent performanceStatisticsHelper = statistics.performanceStatisticsHelper; FramesCollection frames = performanceStatisticsHelper.frames; PerformanceStatisticData data = new PerformanceStatisticData { UserName = selfUser.userUid.Uid, GraphicDeviceName = SystemInfo.graphicsDeviceName, GraphicsDeviceType = SystemInfo.graphicsDeviceType.ToString(), GraphicsMemorySize = SystemInfo.graphicsMemorySize, DefaultQuality = GraphicsSettings.INSTANCE.DefaultQuality.Name, Quality = QualitySettings.names[QualitySettings.GetQualityLevel()], Resolution = GraphicsSettings.INSTANCE.CurrentResolution.ToString(), MapName = GetMapName(map), BattleRoundTimeInMin = (int)((Time.realtimeSinceStartup - performanceStatisticsHelper.startRoundTimeInSec) / 60f), TankCountModa = performanceStatisticsHelper.tankCount.Moda, Moda = frames.Moda, Average = frames.Average, StandardDeviationInMs = frames.StandartDevation, HugeFrameCount = frames.HugeFrameCount, MinAverageForInterval = frames.MinAverageForInterval, MaxAverageForInterval = frames.MaxAverageForInterval, GraphicDeviceKey = $"DeviceVendorID: {SystemInfo.graphicsDeviceVendorID}; DeviceID: {SystemInfo.graphicsDeviceID}", AveragePing = battleUser.battlePing.getAveragePing(), PingModa = battleUser.battlePing.getMediana(), GraphicsDeviceVersion = SystemInfo.graphicsDeviceVersion, CustomSettings = GraphicsSettings.INSTANCE.customSettings, Windowed = !Screen.fullScreen, SaturationLevel = GraphicsSettings.INSTANCE.CurrentSaturationLevel, VegetationLevel = GraphicsSettings.INSTANCE.CurrentVegetationLevel, GrassLevel = GraphicsSettings.INSTANCE.CurrentGrassLevel, AntialiasingQuality = GraphicsSettings.INSTANCE.CurrentAntialiasingQuality, AnisotropicQuality = GraphicsSettings.INSTANCE.CurrentAnisotropicQuality, TextureQuality = GraphicsSettings.INSTANCE.CurrentTextureQuality, ShadowQuality = GraphicsSettings.INSTANCE.CurrentShadowQuality, AmbientOcclusion = GraphicsSettings.INSTANCE.currentAmbientOcclusion, Bloom = GraphicsSettings.INSTANCE.currentBloom, RenderResolutionQuality = GraphicsSettings.INSTANCE.CurrentRenderResolutionQuality, SystemMemorySize = SystemInfo.systemMemorySize, TotalReservedMemory = (long)Profiler.GetTotalReservedMemory(), TotalAllocatedMemory = (long)Profiler.GetTotalAllocatedMemory(), MonoHeapSize = (long)Profiler.GetMonoHeapSize(), HandlerNames = new string[0], HandlerCallCounts = new int[0] }; base.Log.InfoFormat("{0}\n{1}", "PerformanceStatisticData", EcsToStringUtil.ToStringWithProperties(data, ", ")); base.ScheduleEvent(new SendPerfomanceStatisticDataEvent(data), selfUser); } }
public void InitMeasuringOnRoundStart(NodeAddedEvent e, RoundUserNode roundUser, [Context, JoinByUser] BattleUserNode selfBattleUser, [JoinAll] StatisticsNode statistics) { PerformanceStatisticsHelperComponent performanceStatisticsHelper = statistics.performanceStatisticsHelper; PerformanceStatisticsSettingsComponent performanceStatisticsSettings = statistics.performanceStatisticsSettings; performanceStatisticsHelper.startRoundTimeInSec = UnityTime.realtimeSinceStartup; performanceStatisticsHelper.frames = new FramesCollection(performanceStatisticsSettings.HugeFrameDurationInMs, performanceStatisticsSettings.MeasuringIntervalInSec); performanceStatisticsHelper.tankCount = new StatisticCollection(50); }
public void Update(TimeUpdateEvent e, BattleUserNode selfBattleUser, [JoinByUser] SingleNode <RoundUserComponent> selfRoundUser, [JoinByBattle] ICollection <SingleNode <RoundUserComponent> > allRoundUsers, [JoinAll] StatisticsNode statistics) { if (!RoundTimeTooShortForMeasuring(statistics)) { PerformanceStatisticsHelperComponent performanceStatisticsHelper = statistics.performanceStatisticsHelper; int durationInMs = (int)(e.DeltaTime * 1000f); performanceStatisticsHelper.frames.AddFrame(durationInMs); performanceStatisticsHelper.tankCount.Add(allRoundUsers.Count, durationInMs); } }