public bool Equals(SysInfoData other) { if (this.type != other.type) { return(false); } if (this.text != other.text) { return(false); } if (this.itemId != other.itemId) { return(false); } if (this.itemCount != other.itemCount) { return(false); } if (this.money != other.money) { return(false); } if (this.exp != other.exp) { return(false); } if (this.diamond != other.diamond) { return(false); } return(true); }
/* void Update() * { * print("还是执行了"); * UpdateSysInfo(); * }*/ public void ChangeWidth(GameObject go, SysInfoData msgData) { RectTransform rt = go.GetComponent <RectTransform>(); UIWrapper wrapper = go.GetComponent <UIWrapper>(); UIWrapper text = wrapper.GO("Text"); string str = wrapper.GO("Text").text; if (str.Contains("</color>")) { str = getTextStr(msgData.text); } int length = (int)text.textWidth; switch (msgData.type) { case SysInfoType.Text: case SysInfoType.Item: rt.sizeDelta = new Vector2(length + 80, 40); break; case SysInfoType.Money: case SysInfoType.Diamond: case SysInfoType.Exp: UIWrapper icon = wrapper.GO("Icon"); rt.sizeDelta = new Vector2(40 + 28 + 10 + length + 40, 40); //前间隔、图标宽度、图标和文本间隔、文本宽度、后间隔 icon.GetComponent <RectTransform>().anchoredPosition = new Vector3(40, 0, 0); text.GetComponent <RectTransform>().anchoredPosition = new Vector3(-40, 0, 0); break; default: return; } }
/// <summary> /// 执行文本信息 /// </summary> /// <param name="msgData"></param> public GameObject DoTextMsg(SysInfoData msgData) { GameObject go = GameObject.Instantiate(msgObj) as GameObject; TextFly adpation = go.GetComponent <TextFly>(); Text text = go.GetComponentInChildren <Text>(); text.text = msgData.text; return(go); }
public GameObject DoExpMsg(SysInfoData msgData) { GameObject go = GameObject.Instantiate(expMsg) as GameObject; TextFly adpation = go.GetComponent <TextFly>(); Text text = go.GetComponentInChildren <Text>(); text.text = string.Format("+{0}", msgData.exp); go.SetActive(true); return(go); }
private SysInfoData CreateChartData(SysInfoItem sysInfoItem) { SysInfoData chartData; if (_sysInfoStartTimeSeconds < 0) { _sysInfoStartTimeSeconds = sysInfoItem.TimeSeconds; DebugWrite($"System info start time: {_sysInfoStartTimeSeconds.UnixTimeToDateTime().ToString("yyyy-MM-dd HH:mm:ss.fff")} Z"); LiveTimeline.AxisY[0].Title = String.Format($"CPU (% of {sysInfoItem.CoreNum} processors)"); LiveTimeline.AxisY[1].MaxValue = Math.Ceiling(sysInfoItem.MemTotal / 1024.0); chartData = new SysInfoData(); } else { if (sysInfoItem.TimeSeconds < _sysInfoStartTimeSeconds) { return(null); } double time = (sysInfoItem.TimeSeconds - _sysInfoStartTimeSeconds); if ((time + ViewPortTimeReserve) > _rangeMaxValue) { bool atTheEnd = (ScrollBar.Maximum - ScrollBar.Value) < 1; _rangeMaxValue += ViewPortTimeReserve; UpdateScrollBar(); // Scroll to the end if we were at the end already if (atTheEnd) { Offset = ScrollBar.Maximum; } } chartData = new SysInfoData() { TimeSeconds = time }; if (_previousSysInfo != null) { double timeDelta = (sysInfoItem.TimeSeconds - _previousSysInfo.TimeSeconds); if (timeDelta >= 0.001) { chartData.CpuPercent = Math.Min(Math.Max((sysInfoItem.UserSys - _previousSysInfo.UserSys) / timeDelta / sysInfoItem.CoreNum, 0), 100); } } } chartData.Running = ProfilerStatusToBool(sysInfoItem.ProfilerStatus); chartData.MemoryMiB = sysInfoItem.MemLoad / 1024.0; return(chartData); }
static int DoTextMsg(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); SysInfoLayer obj = (SysInfoLayer)ToLua.CheckObject(L, 1, typeof(SysInfoLayer)); SysInfoData arg0 = (SysInfoData)ToLua.CheckObject(L, 2, typeof(SysInfoData)); UnityEngine.GameObject o = obj.DoTextMsg(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int ChangeWidth(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); SysInfoLayer obj = (SysInfoLayer)ToLua.CheckObject(L, 1, typeof(SysInfoLayer)); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject)); SysInfoData arg1 = (SysInfoData)ToLua.CheckObject(L, 3, typeof(SysInfoData)); obj.ChangeWidth(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void ProcessTargetSysInfo(SysInfoItem sysInfo) { if (_session != null) { Dispatcher.Invoke(() => { SysInfoData chartData = CreateChartData(sysInfo); if (chartData != null) { AddDataToChart(chartData); _previousSysInfo = sysInfo; _previousChartData = chartData; } }); } }
private void ClearSession(bool hideScrollbar) { if (_session != null) { _session.RemoveListener(_sessionListener); _session = null; } DisposeHelper.SafeDispose(ref _sysInfoProcessor); DisposeHelper.SafeDispose(ref _eventsProcessor); ViewPortMinValue = 0; ViewPortMaxValue = ViewPortSize; _chartValues.Clear(); _jitSeriesValues.Clear(); _jitEventProcessor.Clear(); _gcSeriesValues.Clear(); _gcEventProcessor.Clear(); LiveTimeline.AxisX[0].Sections.Clear(); LiveTimeline.AxisY[1].MaxValue = 1000; LiveTimeline.Update(true, true); _rangeMaxValue = ViewPortSize; _sysInfoStartTimeSeconds = -1; _profilingEventsDeltaSeconds = 0; _sysInfoEventsDeltaSeconds = 0; _areDeltasSet = false; _previousSysInfo = null; _previousChartData = null; _currentPausedSection = null; _currentDebugBreakSection = null; UpdateScrollBar(hideScrollbar); SessionControlButton.Visibility = Visibility.Collapsed; SessionControlButton.IsEnabled = false; _session = null; }
} // ProfilerEventProcessor private void AddDataToChart(SysInfoData sysInfoData) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); if (!_areDeltasSet && (_sysInfoStartTimeSeconds >= 0)) { DateTime profilerStartTimeUtc = _session.ProfilerStartTimeUtc; if (profilerStartTimeUtc != DateTime.MinValue) { _areDeltasSet = true; DateTime sysInfoStartTime = _sysInfoStartTimeSeconds.UnixTimeToDateTime(); _profilingEventsDeltaSeconds = (profilerStartTimeUtc - sysInfoStartTime).TotalSeconds; if (_profilingEventsDeltaSeconds < 0) { _sysInfoEventsDeltaSeconds = -_profilingEventsDeltaSeconds; _profilingEventsDeltaSeconds = 0; } // update existing chart items var savedSeries = new List <ISeriesView>(SeriesCollection); SeriesCollection.Clear(); SeriesCollection.AddRange(savedSeries); DebugWrite( $"Profiler start time: {profilerStartTimeUtc.ToString("yyyy-MM-dd HH:mm:ss.fff")} Z. " + $"Profiling events delta: {_profilingEventsDeltaSeconds:F3} s. " + $"System information events delta: {_sysInfoEventsDeltaSeconds:F3} s"); } } bool isBreakState = (ProfilerPlugin.Instance.DebugMode == Microsoft.VisualStudio.Shell.Interop.DBGMODE.DBGMODE_Break); if (_isBreakState != isBreakState) // happens sometimes { _isBreakState = isBreakState; UpdateControlsOnDebugStateChange(isBreakState); } if (_currentDebugBreakSection != null) { _currentDebugBreakSection.SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds - _currentDebugBreakSection.Value; if (!_isBreakState) { DebugWrite($"Debug break section finished. Duration is {_currentDebugBreakSection.SectionWidth:F3} sec"); _currentDebugBreakSection = null; } } else if (_isBreakState) { if (_currentDebugBreakSection == null) { _currentDebugBreakSection = new AxisSection() { Value = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, SectionWidth = 0.001, // 1 msec Fill = DebugBreakSectionBrush }; LiveTimeline.AxisX[0].Sections.Add(_currentDebugBreakSection); DebugWrite($"Debug break section started at {_currentDebugBreakSection.Value:F3} sec"); } } AxisSection newPausedSection = null; if (sysInfoData.Running) { if ((_previousChartData != null) && !_previousChartData.Running) { _currentPausedSection = null; } } else { if (_previousChartData != null) { if (_previousChartData.Running) { newPausedSection = new AxisSection() { Value = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, SectionWidth = 0.001, // 1 msec /*!! Value = _previousChartData.TimeSeconds + _sysInfoEventsDeltaSeconds, * SectionWidth = sysInfoData.TimeSeconds - _previousChartData.TimeSeconds,*/ }; } } else { newPausedSection = new AxisSection() { Value = 0, SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, }; } } if (newPausedSection != null) { newPausedSection.Fill = PausedSectionBrush; _currentPausedSection = newPausedSection; LiveTimeline.AxisX[0].Sections.Add(_currentPausedSection); } else if (_currentPausedSection != null) { _currentPausedSection.SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds - _currentPausedSection.Value; } _chartValues.Add(sysInfoData); List <ClrJobItem> newClrJobItems; newClrJobItems = _jitEventProcessor.TakeJobItems(); if (newClrJobItems != null) { AddClrJobItems(_jitSeriesValues, newClrJobItems, "JIT"); } newClrJobItems = _gcEventProcessor.TakeJobItems(); if (newClrJobItems != null) { AddClrJobItems(_gcSeriesValues, newClrJobItems, "GC"); } }