Exemple #1
0
        public static Sample Deserialize(byte[] data)
        {
            Sample       s  = new Sample();
            MemoryStream ms = new MemoryStream(data);
            BinaryReader b  = new BinaryReader(ms);

            s.calls      = b.ReadInt32();
            s.frameCount = b.ReadInt32();
            s.fps        = b.ReadSingle();
            s.pss        = b.ReadInt32();
            s.power      = b.ReadSingle();
            s.costLuaGC  = b.ReadInt32();
            s.costMonoGC = b.ReadInt32();

            int len = b.ReadInt32();

            byte[] datas = b.ReadBytes(len);
            s.name     = Encoding.UTF8.GetString(datas);
            s.costTime = b.ReadInt32();

            int childCount = b.ReadInt32();

            for (int i = 0; i < childCount; i++)
            {
                len   = b.ReadInt32();
                datas = b.ReadBytes(len);
                Sample child = Deserialize(datas);
                child.fahter = s;
            }

            bool hasCapture = b.ReadBoolean();

            if (hasCapture)
            {
                len          = b.ReadInt32();
                datas        = b.ReadBytes(len);
                s.captureUrl = Encoding.UTF8.GetString(datas);

                if (!File.Exists(s.captureUrl))
                {
                    string dir = Path.GetDirectoryName(s.captureUrl);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    len   = b.ReadInt32();
                    datas = b.ReadBytes(len);
                    //写入图片数据
                    File.WriteAllBytes(s.captureUrl, datas);
                }
            }
            s.currentLuaMemory  = b.ReadInt32();
            s.currentMonoMemory = b.ReadInt32();

            int lua_gc = 0;

            foreach (var item in s.childs)
            {
                lua_gc += item.costLuaGC;
            }
            s.costLuaGC = Math.Max(lua_gc, s.costLuaGC);
            int mono_gc = 0;

            foreach (var item in s.childs)
            {
                mono_gc += item.costMonoGC;
            }
            s.costMonoGC = Math.Max(mono_gc, s.costMonoGC);

            b.Close();

            return(s);
        }
Exemple #2
0
        public static Sample Create()
        {
            Sample s = samplePool.GetObject();

            return(s);
        }