Exemplo n.º 1
0
        public ProfileReport(string file)
        {
            bool in_profile;
            ProfileType type;
            string cur_report;
            XmlTextReader xml;

            xml = new XmlTextReader(file);
            xml.WhitespaceHandling = WhitespaceHandling.None;

            m_Items = new List<ProfileItem>();

            type = ProfileType.ProfType_Unknown;
            in_profile = false;
            cur_report = null;
            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.Element)
                {
                    if (xml.Name.CompareTo("profile") == 0)
                    {
                        int t;
                        in_profile = true;
                        m_duration = Double.Parse(xml.GetAttribute("uptime"));
                        m_start_time = new DateTime(1970, 1, 1, 0, 0, 0);
                        t = Int32.Parse(xml.GetAttribute("time"));
                        m_start_time = m_start_time.AddSeconds(t);
                    }
                    else if (in_profile)
                    {
                        if (xml.Name.CompareTo("report") == 0)
                        {
                            cur_report = xml.GetAttribute("name");
                            if (cur_report.CompareTo("natives") == 0)
                            {
                                type = ProfileType.ProfType_Native;
                            }
                            else if (cur_report.CompareTo("callbacks") == 0)
                            {
                                type = ProfileType.ProfType_Callback;
                            }
                            else if (cur_report.CompareTo("functions") == 0)
                            {
                                type = ProfileType.ProfType_Function;
                            }
                            else
                            {
                                type = ProfileType.ProfType_Unknown;
                            }
                        }
                        else if (xml.Name.CompareTo("item") == 0 && cur_report != null)
                        {
                            ProfileItem item;

                            item = new ProfileItem();
                            item.name = xml.GetAttribute("name");
                            item.max_time = Double.Parse(xml.GetAttribute("maxtime"));
                            item.min_time = Double.Parse(xml.GetAttribute("mintime"));
                            item.num_calls = UInt32.Parse(xml.GetAttribute("numcalls"));
                            item.total_time = Double.Parse(xml.GetAttribute("totaltime"));
                            item.type = type;
                            m_Items.Add(item);
                        }
                    }
                }
                else if (xml.NodeType == XmlNodeType.EndElement)
                {
                    if (xml.Name.CompareTo("profile") == 0)
                    {
                        break;
                    }
                    else if (xml.Name.CompareTo("report") == 0)
                    {
                        cur_report = null;
                    }
                }
            }
            xml.Close();
        }
Exemplo n.º 2
0
        public ProfileReport(string file)
        {
            bool          in_profile;
            ProfileType   type;
            string        cur_report;
            XmlTextReader xml;

            xml = new XmlTextReader(file);
            xml.WhitespaceHandling = WhitespaceHandling.None;

            m_Items = new List <ProfileItem>();

            type       = ProfileType.ProfType_Unknown;
            in_profile = false;
            cur_report = null;
            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.Element)
                {
                    if (xml.Name.CompareTo("profile") == 0)
                    {
                        int t;
                        in_profile   = true;
                        m_duration   = Double.Parse(xml.GetAttribute("uptime"));
                        m_start_time = new DateTime(1970, 1, 1, 0, 0, 0);
                        t            = Int32.Parse(xml.GetAttribute("time"));
                        m_start_time = m_start_time.AddSeconds(t);
                    }
                    else if (in_profile)
                    {
                        if (xml.Name.CompareTo("report") == 0)
                        {
                            cur_report = xml.GetAttribute("name");
                            if (cur_report.CompareTo("natives") == 0)
                            {
                                type = ProfileType.ProfType_Native;
                            }
                            else if (cur_report.CompareTo("callbacks") == 0)
                            {
                                type = ProfileType.ProfType_Callback;
                            }
                            else if (cur_report.CompareTo("functions") == 0)
                            {
                                type = ProfileType.ProfType_Function;
                            }
                            else
                            {
                                type = ProfileType.ProfType_Unknown;
                            }
                        }
                        else if (xml.Name.CompareTo("item") == 0 && cur_report != null)
                        {
                            ProfileItem item;

                            item            = new ProfileItem();
                            item.name       = xml.GetAttribute("name");
                            item.max_time   = Double.Parse(xml.GetAttribute("maxtime"));
                            item.min_time   = Double.Parse(xml.GetAttribute("mintime"));
                            item.num_calls  = UInt32.Parse(xml.GetAttribute("numcalls"));
                            item.total_time = Double.Parse(xml.GetAttribute("totaltime"));
                            item.type       = type;
                            m_Items.Add(item);
                        }
                    }
                }
                else if (xml.NodeType == XmlNodeType.EndElement)
                {
                    if (xml.Name.CompareTo("profile") == 0)
                    {
                        break;
                    }
                    else if (xml.Name.CompareTo("report") == 0)
                    {
                        cur_report = null;
                    }
                }
            }
        }