示例#1
0
    public void StopStats()
    {
        if (!enabled)
        {
            return;
        }

        enabled = false;

        float seconds = Time.time - m_startTime;

        List <string> content       = new List <string>();
        int           frameRecorded = Time.frameCount - m_startFrame;

        content.Add(string.Format("name \ttotalMS \tperFrameMS \trebuildCount \tupdateCount \tdrawcallCount/updateCount \t --- {0} frames ---", frameRecorded));

        {
            List <KeyValuePair <int, UIPanelData> > panelData = m_accumulatedPanels.ToList();
            panelData.Sort(
                delegate(KeyValuePair <int, UIPanelData> pair1,
                         KeyValuePair <int, UIPanelData> pair2)
            {
                return(pair2.Value.mElapsedTicks.CompareTo(pair1.Value.mElapsedTicks));
            }
                );

            foreach (var p in panelData)
            {
                string      name = UIDebugCache.GetName(p.Key);
                UIPanelData data = p.Value;
                content.Add(string.Format("{0}\t{1:0.00}\t{2:0.00}\t{3}\t{4}\t{5}",
                                          name, data.mElapsedTicks, data.mElapsedTicks / (double)frameRecorded,
                                          (int)(data.mRebuildCount / seconds), (int)(data.mCalls / seconds), data.mDrawCallNum / data.mCalls));
            }
        }

        List <KeyValuePair <int, double> > sortBuf = m_accumulated.ToList();

        sortBuf.Sort(
            delegate(KeyValuePair <int, double> pair1,
                     KeyValuePair <int, double> pair2)
        {
            return(pair2.Value.CompareTo(pair1.Value));
        }
            );

        foreach (var p in sortBuf)
        {
            string name       = UIDebugCache.GetName(p.Key);
            string parentName = UIDebugCache.GetParentName(p.Key);
            if (!string.IsNullOrEmpty(parentName))
            {
                name = string.Format("{0}:{1}", parentName, name);
            }
            content.Add(string.Format("{0}\t{1:0.00}\t{2:0.00}", name, p.Value, p.Value / (double)frameRecorded));
        }
        string file = Path.Combine(Application.persistentDataPath, string.Format("TestTools/ui_stats_panels_{0}_{1}.log", SysUtil.FormatDateAsFileNameString(DateTime.Now), SysUtil.FormatTimeAsFileNameString(DateTime.Now)));

        System.IO.File.WriteAllLines(file, content.ToArray());
    }
示例#2
0
    public string PrintDictDouble()
    {
        List <KeyValuePair <int, UIPanelData> > l = m_elapsedTicks.ToList();

        l.Sort(
            delegate(KeyValuePair <int, UIPanelData> pair1, KeyValuePair <int, UIPanelData> pair2)
        {
            return(Math.Sign(pair2.Value.mElapsedTicks - pair1.Value.mElapsedTicks));
        }
            );

        StringBuilder builder = new StringBuilder();

        foreach (var p in l)
        {
            builder.AppendFormat("{0, -30} \t{1:0.00} \t{2:0.00} \t{3}/{4} \t{5}\n",
                                 UIDebugCache.GetName(p.Key), p.Value.mElapsedTicks, p.Value.mElapsedTicks / (double)(1.0f / Time.deltaTime), p.Value.mRebuildCount, p.Value.mCalls, p.Value.mDrawCallNum / p.Value.mCalls);

            if (UIDebugVariables.ShowWidgetStatsOnScreen)
            {
                UITimingDict dict = null;
                if (m_widgetTicks.TryGetValue(p.Key, out dict))
                {
                    builder.AppendFormat("{0}\n", dict.PrintDict(5));
                }
            }
        }
        return(builder.ToString());
    }
    public void StopStats()
    {
        if (!((Behaviour)this).get_enabled())
        {
            return;
        }
        ((Behaviour)this).set_enabled(false);
        float         num1       = Time.get_time() - this.m_startTime;
        List <string> stringList = new List <string>();
        int           num2       = Time.get_frameCount() - this.m_startFrame;

        stringList.Add(string.Format("name \ttotalMS \tperFrameMS \trebuildCount \tupdateCount \tdrawcallCount/updateCount \t --- {0} frames ---", (object)num2));
        List <KeyValuePair <int, UIPanelData> > list1 = this.m_accumulatedPanels.ToList <KeyValuePair <int, UIPanelData> >();

        list1.Sort((Comparison <KeyValuePair <int, UIPanelData> >)((pair1, pair2) => pair2.Value.mElapsedTicks.CompareTo(pair1.Value.mElapsedTicks)));
        foreach (KeyValuePair <int, UIPanelData> keyValuePair in list1)
        {
            string      name        = UIDebugCache.GetName(keyValuePair.Key);
            UIPanelData uiPanelData = keyValuePair.Value;
            stringList.Add(string.Format("{0}\t{1:0.00}\t{2:0.00}\t{3}\t{4}\t{5}", (object)name, (object)uiPanelData.mElapsedTicks, (object)(uiPanelData.mElapsedTicks / (double)num2), (object)(int)((double)uiPanelData.mRebuildCount / (double)num1), (object)(int)((double)uiPanelData.mCalls / (double)num1), (object)(uiPanelData.mDrawCallNum / uiPanelData.mCalls)));
        }
        List <KeyValuePair <int, double> > list2 = this.m_accumulated.ToList <KeyValuePair <int, double> >();

        list2.Sort((Comparison <KeyValuePair <int, double> >)((pair1, pair2) => pair2.Value.CompareTo(pair1.Value)));
        foreach (KeyValuePair <int, double> keyValuePair in list2)
        {
            string str        = UIDebugCache.GetName(keyValuePair.Key);
            string parentName = UIDebugCache.GetParentName(keyValuePair.Key);
            if (!string.IsNullOrEmpty(parentName))
            {
                str = string.Format("{0}:{1}", (object)parentName, (object)str);
            }
            stringList.Add(string.Format("{0}\t{1:0.00}\t{2:0.00}", (object)str, (object)keyValuePair.Value, (object)(keyValuePair.Value / (double)num2)));
        }
        File.WriteAllLines(Path.Combine(Application.get_persistentDataPath(), string.Format("TestTools/ui_stats_panels_{0}_{1}.log", (object)SysUtil.FormatDateAsFileNameString(DateTime.Now), (object)SysUtil.FormatTimeAsFileNameString(DateTime.Now))), stringList.ToArray());
    }
示例#4
0
    public string PrintDict(int count = -1)
    {
        List <KeyValuePair <int, double> > l = m_elapsedTicks.ToList();

        l.Sort(
            delegate(KeyValuePair <int, double> pair1, KeyValuePair <int, double> pair2)
        {
            return(Math.Sign(pair2.Value - pair1.Value));
        }
            );

        if (count > 0 && count < l.Count)
        {
            l.RemoveRange(count - 1, l.Count - count);
        }

        StringBuilder builder = new StringBuilder();

        foreach (var p in l)
        {
            builder.AppendFormat("{0}{1,-40} \t{2:0.00} \t{3:0.00}\n", Indent, UIDebugCache.GetName(p.Key), p.Value, p.Value / (double)(1.0f / Time.deltaTime));
        }
        return(builder.ToString());
    }
    public string PrintDictDouble()
    {
        List <KeyValuePair <int, UIPanelData> > list = this.m_elapsedTicks.ToList <KeyValuePair <int, UIPanelData> >();

        list.Sort((Comparison <KeyValuePair <int, UIPanelData> >)((pair1, pair2) => Math.Sign(pair2.Value.mElapsedTicks - pair1.Value.mElapsedTicks)));
        StringBuilder stringBuilder = new StringBuilder();

        foreach (KeyValuePair <int, UIPanelData> keyValuePair in list)
        {
            stringBuilder.AppendFormat("{0, -30} \t{1:0.00} \t{2:0.00} \t{3}/{4} \t{5}\n", (object)UIDebugCache.GetName(keyValuePair.Key), (object)keyValuePair.Value.mElapsedTicks, (object)(keyValuePair.Value.mElapsedTicks / (1.0 / (double)Time.get_deltaTime())), (object)keyValuePair.Value.mRebuildCount, (object)keyValuePair.Value.mCalls, (object)(keyValuePair.Value.mDrawCallNum / keyValuePair.Value.mCalls));
            if (UIDebugVariables.ShowWidgetStatsOnScreen)
            {
                UITimingDict uiTimingDict = (UITimingDict)null;
                if (this.m_widgetTicks.TryGetValue(keyValuePair.Key, out uiTimingDict))
                {
                    stringBuilder.AppendFormat("{0}\n", (object)uiTimingDict.PrintDict(5));
                }
            }
        }
        return(stringBuilder.ToString());
    }
    public string PrintDict(int count = -1)
    {
        List <KeyValuePair <int, double> > list = this.m_elapsedTicks.ToList <KeyValuePair <int, double> >();

        list.Sort((Comparison <KeyValuePair <int, double> >)((pair1, pair2) => Math.Sign(pair2.Value - pair1.Value)));
        if (count > 0 && count < list.Count)
        {
            list.RemoveRange(count - 1, list.Count - count);
        }
        StringBuilder stringBuilder = new StringBuilder();

        foreach (KeyValuePair <int, double> keyValuePair in list)
        {
            stringBuilder.AppendFormat("{0}{1,-40} \t{2:0.00} \t{3:0.00}\n", (object)"    ", (object)UIDebugCache.GetName(keyValuePair.Key), (object)keyValuePair.Value, (object)(keyValuePair.Value / (1.0 / (double)Time.get_deltaTime())));
        }
        return(stringBuilder.ToString());
    }