コード例 #1
0
        internal SerializableProfiler ParseSessionFields(JsonObject sessionJson)
        {
            var session = new SerializableProfiler();
            session.Client = sessionJson["client"];
            session.DurationMilliseconds = ParseInt64(sessionJson["duration"]).GetValueOrDefault();
            session.MachineName = sessionJson["machine"];
            session.StartMilliseconds = ParseInt64(sessionJson["start"]).GetValueOrDefault();
            session.Sort = ParseInt64(sessionJson["sort"]).GetValueOrDefault(session.StartMilliseconds);
            session.Started = ParseDateTime(sessionJson["started"]);
            session.ExecuteType = sessionJson["executeType"];
            session.Id = ParseGuid(sessionJson["id"]);
            session.LocalAddress = sessionJson["localAddress"];
            session.Name = sessionJson["name"];
            session.Type = sessionJson["type"];
            if (sessionJson.ContainsKey("tags")) session.Tags = ParseTags(sessionJson.Child("tags"));

            return session;
        }
コード例 #2
0
        internal void SortSessionTimings(SerializableProfiler session)
        {
            // ensure the first step is root
            if (session.StepTimings != null && session.StepTimings.Count > 0
                && session.StepTimings[0].Name != "root")
            {
                var temp = session.StepTimings[0];
                for (var i = 0; i < session.StepTimings.Count; ++i)
                {
                    if (session.StepTimings[i].Name == "root")
                    {
                        session.StepTimings[0] = session.StepTimings[i];
                        session.StepTimings[i] = temp;
                        break;
                    }
                }
            }

            // order step timings by sort
            if (session.StepTimings != null && session.StepTimings.Count > 0)
            {
                session.StepTimings = session.StepTimings.OrderBy(s => s.Sort).ToList();
            }

            // order custom timings by start milliseconds
            if (session.CustomTimings != null && session.CustomTimings.Count > 0)
            {
                session.CustomTimings = session.CustomTimings.OrderBy(s => s.Sort).ToList();
            }
        }