Exemplo n.º 1
0
            public int Compare(object x, object y)
            {
                ListViewItem    lhsItem = x as ListViewItem;
                ListViewItem    rhsItem = y as ListViewItem;
                LuaProfileEntry lhs     = lhsItem.Tag as LuaProfileEntry;
                LuaProfileEntry rhs     = rhsItem.Tag as LuaProfileEntry;

                switch (m_sortColumn)
                {
                case 0: return(m_sortOrder * String.Compare(lhs.m_function, rhs.m_function));

                case 1:
                {
                    int result = String.Compare(lhs.m_file, rhs.m_file);
                    if (result == 0)
                    {
                        result = lhs.m_line - rhs.m_line;
                    }
                    return(m_sortOrder * result);
                }

                case 2: return(m_sortOrder * String.Compare(lhs.m_language, rhs.m_language));

                case 3: return(m_sortOrder * (lhs.m_count - rhs.m_count));

                case 4: return(m_sortOrder * Math.Sign(lhs.m_timeSelf - rhs.m_timeSelf));

                case 5: return(m_sortOrder * Math.Sign(lhs.m_timeChildren - rhs.m_timeChildren));

                case 6: return(m_sortOrder * Math.Sign((lhs.m_timeSelf + lhs.m_timeChildren) - (rhs.m_timeSelf + rhs.m_timeChildren)));

                default: return(0);
                }
            }
Exemplo n.º 2
0
        private bool Load(Stream stream)
        {
            if (stream == null)
            {
                return(true);
            }

            XmlDocument document = new XmlDocument();

            document.Load(stream);

            // name (class::method) [C]
            // name (C function 0x00000000) [C]
            // name (file:line) [Lua]
            string languageExpr   = @"\[(?<language>\w*)\]";
            string sourceLineExpr = @"(?<source>[^:)]*):(?<line>\d+)";
            string detailsExpr    = @"(?<details>[^)]*)";
            string nameExpr       = @"(?<name>.*?)?";
            Regex  functionRegex  = new Regex(@"^" + nameExpr + @"\s*\((?:" + sourceLineExpr + "|" + detailsExpr + @")\)\s*" + languageExpr + "$");

            XmlNode profileNode = document.SelectSingleNode("luaprofile");

            foreach (XmlElement functionNode in profileNode.SelectNodes("function"))
            {
                string name = functionNode.GetAttribute("name");

                string function     = name;
                string file         = "";
                int    line         = -1;
                int    count        = 0;
                double time         = 0;
                double timeChildren = 0;
                string language     = "?";

                Match match = functionRegex.Match(name);
                if (match.Success)
                {
                    string details = match.Groups["details"].Value;
                    function = match.Groups["name"].Value;
                    language = match.Groups["language"].Value;
                    file     = match.Groups["source"].Value;
                    Int32.TryParse(match.Groups["line"].Value, out line);
                    if (file == "")
                    {
                        file = details;
                    }
                }

                Int32.TryParse(functionNode.GetAttribute("call_count"), out count);
                Double.TryParse(functionNode.GetAttribute("self"), out time);
                Double.TryParse(functionNode.GetAttribute("children"), out timeChildren);

                LuaProfileEntry entry = new LuaProfileEntry(name, function, language, file, line, count, time, timeChildren);
                m_functions.Add(entry);
            }

            return(true);
        }
Exemplo n.º 3
0
        private void profileListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    count    = 0;
            double self     = 0;
            double children = 0;

            foreach (ListViewItem item in profileListView.SelectedItems)
            {
                LuaProfileEntry entry = item.Tag as LuaProfileEntry;
                count    += entry.m_count;
                self     += entry.m_timeSelf;
                children += entry.m_timeChildren;
            }

            string countStr, selfStr, childrenStr, totalTimeStr;

            if (m_displayMode == DisplayMode.Percentages)
            {
                countStr     = ((double)count / (double)m_totalCount).ToString("0.0000%");
                selfStr      = (self / m_totalTime).ToString("0.0000%");
                childrenStr  = (children / m_totalTimeChildren).ToString("0.0000%");
                totalTimeStr = ((self + children) / (m_totalTime + m_totalTimeChildren)).ToString("0.0000%");
            }
            else if (m_displayMode == DisplayMode.Milliseconds)
            {
                countStr     = count.ToString();
                selfStr      = (self * 1000.0).ToString("0.00000");
                childrenStr  = (children * 1000.0).ToString("0.00000");
                totalTimeStr = ((self + children) * 1000.0).ToString("0.00000");
            }
            else
            {
                countStr     = count.ToString();
                selfStr      = (self).ToString("0.00000");
                childrenStr  = (children).ToString("0.00000");
                totalTimeStr = ((self + children)).ToString("0.00000");
            }

            Manager.SetStatusMessage(
                String.Format("TOTAL Count={0}, Self={1}, Children={2}, Total Time={3}", countStr, selfStr, childrenStr, totalTimeStr),
                0f);
        }
Exemplo n.º 4
0
        private void profileListView_ItemActivate(object sender, EventArgs e)
        {
            if (profileListView.SelectedItems.Count > 0)
            {
                LuaProfileEntry entry = profileListView.SelectedItems[0].Tag as LuaProfileEntry;
                if (entry.m_language == "Lua")
                {
                    Document doc = Manager.OpenDocument(entry.m_file);
                    if (doc != null)
                    {
                        DocumentView docView = Manager.ShowDocument(doc);

                        Tilde.LuaDebugger.LuaScriptView luaView = docView as Tilde.LuaDebugger.LuaScriptView;

                        if (luaView != null)
                        {
                            luaView.ShowLine(entry.m_line);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
		private bool Load(Stream stream)
		{
			if (stream == null)
				return true;

			XmlDocument document = new XmlDocument();
			document.Load(stream);

			// name (class::method) [C]
			// name (C function 0x00000000) [C]
			// name (file:line) [Lua]
			string languageExpr = @"\[(?<language>\w*)\]";
			string sourceLineExpr = @"(?<source>[^:)]*):(?<line>\d+)";
			string detailsExpr = @"(?<details>[^)]*)";
			string nameExpr = @"(?<name>.*?)?";
			Regex functionRegex = new Regex(@"^" + nameExpr + @"\s*\((?:" + sourceLineExpr + "|" + detailsExpr + @")\)\s*" + languageExpr + "$");

			XmlNode profileNode = document.SelectSingleNode("luaprofile");
			foreach (XmlElement functionNode in profileNode.SelectNodes("function"))
			{
				string name = functionNode.GetAttribute("name");

				string function = name;
				string file = "";
				int line = -1;
				int count = 0;
				double time = 0;
				double timeChildren = 0;
				string language = "?";

				Match match = functionRegex.Match(name);
				if (match.Success)
				{
					string details = match.Groups["details"].Value;
					function = match.Groups["name"].Value;
					language = match.Groups["language"].Value;
					file = match.Groups["source"].Value;
					Int32.TryParse(match.Groups["line"].Value, out line);
					if (file == "")
						file = details;
				}

				Int32.TryParse(functionNode.GetAttribute("call_count"), out count);
				Double.TryParse(functionNode.GetAttribute("self"), out time);
				Double.TryParse(functionNode.GetAttribute("children"), out timeChildren);

				LuaProfileEntry entry = new LuaProfileEntry(name, function, language, file, line, count, time, timeChildren);
				m_functions.Add(entry);
			}

			return true;
		}