예제 #1
0
        public static List<ProfilerNode> DecodeProfilerData(byte[] data)
        {
            List<ProfilerNode> nodes = new List<ProfilerNode>();

            ByteStream stream = new ByteStream(data);
            Protocol.ProfileDataType profilerType = (Protocol.ProfileDataType)stream.ReadBytes(1)[0];
            int fieldsNumber = Protocol.ParseInt(stream);
            for (int i = 0; i < fieldsNumber; ++i)
            {
                int nodeId = Protocol.ParseInt(stream);
                int nodeParentId = Protocol.ParseInt(stream);
                string nodeName = Protocol.ParseString(stream);
                int nodeCount = Protocol.ParseInt(stream);
                float nodeInterval = Protocol.ParseFloat(stream); // in seconds

                ProfilerNode node = new ProfilerNode {
                    id = nodeId,
                    parentId = nodeParentId,
                    name = nodeName,
                    count = nodeCount,
                    interval = nodeInterval
                };

                if (profilerType == Protocol.ProfileDataType.CPU)
                    node.interval *= 1000.0f;

                nodes.Add(node);
            }

            return nodes;
        }
예제 #2
0
 private void FillGlobalVars(byte[] data)
 {
     ByteStream stream = new ByteStream(data);
     while (stream.HasData)
     {
         string varName = Protocol.ParseString(stream);
         int varType = Protocol.ParseInt(stream);
         globalVars.Add(varName, new GlobalVar(varName, varType));
     }
 }
예제 #3
0
 public static string ValueToString(Type type, int valueLength, ByteStream stream)
 {
     switch (type)
     {
     case Type.Int:
         {
             if (valueLength != 4)
                 return "";
             int val = Protocol.ParseInt(stream);
             return val.ToString();
         }
     default:
         return "";
     }
 }
예제 #4
0
        public static string DecodeStats(byte[] data)
        {
            ByteStream stream = new ByteStream(data);
            int viewsNumber = Protocol.ParseInt(stream);
            string res = "";
            for (int i = 0; i < viewsNumber; ++i)
            {
                string viewName = Protocol.ParseString(stream);
                res += viewName;
                res += "\n";
                int fieldsNumber = Protocol.ParseInt(stream);
                for (int j = 0; j < fieldsNumber; ++j)
                {
                    string fieldName = Protocol.ParseString(stream);
                    Type fieldType = (Type)Protocol.ParseInt(stream);
                    int valueLength = Protocol.ParseInt(stream);
                    string fieldValue = ValueToString(fieldType, valueLength, stream);
                    res += string.Format("\t" + fieldName + ":" + fieldValue + "\n");
                }
                res += "\n";
            }

            return res;
        }
예제 #5
0
파일: protocol.cs 프로젝트: icedmaster/mhe
 public static string ParseString(ByteStream stream)
 {
     byte[] len = stream.ReadBytes(4);
     return stream.Read(ConvertToInt(len));
 }
예제 #6
0
파일: protocol.cs 프로젝트: icedmaster/mhe
 public static int ParseInt(ByteStream stream)
 {
     return ConvertToInt(stream.ReadBytes(4));
 }
예제 #7
0
파일: protocol.cs 프로젝트: icedmaster/mhe
 public static float ParseFloat(ByteStream stream)
 {
     byte[] b = stream.ReadBytes(4);
     return System.BitConverter.ToSingle(b, 0);
 }