Exemple #1
0
    public bool NetHandle_RequestStackSummary(eNetCmd cmd, UsCmd c)
    {
        string str = c.ReadString();

        if (string.IsNullOrEmpty(str))
        {
            return(false);
        }
        if (str.Equals("begin"))
        {
            this._stackUnavailableDict.Clear();
            return(true);
        }
        if (str.Equals("end"))
        {
            Debug.Log((object)"Stack Category Statistical Information:");
            int num1   = 0;
            int num2   = 0;
            int bytes1 = 0;
            int bytes2 = 0;
            int num3   = c.ReadInt32();
            for (int index = 0; index < num3; ++index)
            {
                string key = c.ReadString();
                List <ResourceTracker.stackParamater> stackParamaterList;
                this._stackUnavailableDict.TryGetValue(key, out stackParamaterList);
                if (stackParamaterList != null)
                {
                    int num4   = c.ReadInt32();
                    int bytes3 = c.ReadInt32();
                    num1   += num4;
                    bytes1 += bytes3;
                    num2   += stackParamaterList.Count;
                    int bytes4 = 0;
                    foreach (ResourceTracker.stackParamater stackParamater in stackParamaterList)
                    {
                        bytes4 += stackParamater.Size;
                    }
                    bytes2 += bytes4;
                    Debug.Log((object)string.Format("[{0} =({1}/{2},{3}/{4})]", (object)key, (object)stackParamaterList.Count, (object)num4, (object)ResourceTrackerConst.FormatBytes(bytes4), (object)ResourceTrackerConst.FormatBytes(bytes3)));
                }
            }
            Debug.Log((object)string.Format("[total =({0}/{1},{2}/{3})]", (object)num2, (object)num1, (object)ResourceTrackerConst.FormatBytes(bytes2), (object)ResourceTrackerConst.FormatBytes(bytes1)));
            return(true);
        }
        string key1 = str;
        int    num5 = c.ReadInt32();

        for (int index = 0; index < num5; ++index)
        {
            int instID = c.ReadInt32();
            int num1   = c.ReadInt32();
            if (ResourceTracker.Instance.GetAllocInfo(instID) == null)
            {
                if (!this._stackUnavailableDict.ContainsKey(key1))
                {
                    this._stackUnavailableDict.Add(key1, new List <ResourceTracker.stackParamater>());
                }
                List <ResourceTracker.stackParamater> stackParamaterList;
                this._stackUnavailableDict.TryGetValue(key1, out stackParamaterList);
                stackParamaterList.Add(new ResourceTracker.stackParamater()
                {
                    InstanceID = instID,
                    Size       = num1
                });
            }
        }
        return(true);
    }
    public bool NetHandle_RequestStackSummary(eNetCmd cmd, UsCmd c)
    {
        string flag = c.ReadString();

        if (string.IsNullOrEmpty(flag))
        {
            return(false);
        }

        if (flag.Equals("begin"))
        {
            _stackUnavailableDict.Clear();
            return(true);
        }

        if (flag.Equals("end"))
        {
            UnityEngine.Debug.Log("Stack Category Statistical Information:");
            //NetUtil.Log("堆栈类型统计信息:");
            int totalCount            = 0;
            int unavailableTotalCount = 0;
            int totalSize             = 0;
            int unavailableTotalSize  = 0;
            int categoryCount         = c.ReadInt32();
            for (int i = 0; i < categoryCount; i++)
            {
                string category = c.ReadString();
                List <stackParamater> unavailableList;
                _stackUnavailableDict.TryGetValue(category, out unavailableList);
                if (unavailableList != null)
                {
                    int CategoryCount = c.ReadInt32();
                    int CategorySize  = c.ReadInt32();
                    totalCount            += CategoryCount;
                    totalSize             += CategorySize;
                    unavailableTotalCount += unavailableList.Count;
                    int categoryTotalSize = 0;
                    foreach (var info in unavailableList)
                    {
                        categoryTotalSize += info.Size;
                    }
                    unavailableTotalSize += categoryTotalSize;
                    UnityEngine.Debug.Log(string.Format("[{0} =({1}/{2},{3}/{4})]", category, unavailableList.Count, CategoryCount, ResourceTrackerConst.FormatBytes(categoryTotalSize), ResourceTrackerConst.FormatBytes(CategorySize)));
                    //NetUtil.Log("【{0} =({1}/{2},{3}/{4})】", category, unavailableList.Count, CategoryCount, ResourceTrackerConst.FormatBytes(categoryTotalSize), ResourceTrackerConst.FormatBytes(CategorySize));
                }
            }
            UnityEngine.Debug.Log(string.Format("[total =({0}/{1},{2}/{3})]", unavailableTotalCount, totalCount, ResourceTrackerConst.FormatBytes(unavailableTotalSize), ResourceTrackerConst.FormatBytes(totalSize)));
            //NetUtil.Log("【total =({0}/{1},{2}/{3})】", unavailableTotalCount, totalCount, ResourceTrackerConst.FormatBytes(unavailableTotalSize), ResourceTrackerConst.FormatBytes(totalSize));
            return(true);
        }

        string className = flag;
        int    count     = c.ReadInt32();

        for (int i = 0; i < count; i++)
        {
            int instanceID = c.ReadInt32();
            int size       = c.ReadInt32();
            ResourceRequestInfo requestInfo = ResourceTracker.Instance.GetAllocInfo(instanceID);
            if (requestInfo == null)
            {
                if (!_stackUnavailableDict.ContainsKey(className))
                {
                    _stackUnavailableDict.Add(className, new List <stackParamater>());
                }
                List <stackParamater> stackUnavailableList;
                _stackUnavailableDict.TryGetValue(className, out stackUnavailableList);
                stackParamater info = new stackParamater();
                info.InstanceID = instanceID;
                info.Size       = size;
                stackUnavailableList.Add(info);
            }
        }
        return(true);
    }