Exemplo n.º 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;
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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 "";
     }
 }
Exemplo n.º 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;
        }
Exemplo n.º 5
0
 public static string ParseString(ByteStream stream)
 {
     byte[] len = stream.ReadBytes(4);
     return stream.Read(ConvertToInt(len));
 }
Exemplo n.º 6
0
 public static int ParseInt(ByteStream stream)
 {
     return ConvertToInt(stream.ReadBytes(4));
 }
Exemplo n.º 7
0
 public static float ParseFloat(ByteStream stream)
 {
     byte[] b = stream.ReadBytes(4);
     return System.BitConverter.ToSingle(b, 0);
 }