我想解析一些ddump文件,你能幫我加快我的算法嗎?
每個循環需要216 ms!這太方便了。我希望每個迴路有大約40-50毫秒的時間。也許通過使用RegExp?加速解析算法
這裏是我的algrithm:
while (pos < EntireFile.Length && (/*curr = */EntireFile.Substring(pos, EntireFile.Length - pos)).Contains(" class"))
{
w.Reset();
w.Start();
pos = EntireFile.ToLower().IndexOf(" class", pos) + 6;
int end11 = EntireFile.ToLower().IndexOf("extends", pos);
if (end11 == -1)
end11 = EntireFile.IndexOf("\r\n", pos);
else
{
int end22 = EntireFile.IndexOf("\r\n", pos);
if (end22 < end11)
end11 = end22;
}
//string opcods = EntireFile.Substring(pos, EntireFile.Length - pos);
string Cname = EntireFile.Substring(pos, end11 - pos).Trim();
pos += (end11 - pos) + 7;
pos = EntireFile.IndexOf("{", pos) +1;
int count = 1;
string searching = EntireFile.Substring(pos, EntireFile.Length - pos);
int searched = 0;
while (count != 0)
{
if (searching[searched] == '{')
count++;
else if (searching[searched] == '}')
count--;
searched++;
}
string Content = EntireFile.Substring(pos, searched);
tlist.Add(new TClass() { ClassName = Cname, Content = Content });
pos += searched;
if (pos % 3 == 0)
{
double prc = ((double)pos) * 100d/((double)EntireFile.Length);
int prcc = (int)Math.Round(prc);
wnd.UpdateStatus(prcc);
wnd.Update();
}
mils.Add((int)w.ElapsedMilliseconds);
}
任何幫助將不勝感激。
我很好奇,想知道什麼格式轉儲完成文件是。什麼是文件大小?是否有可共享的數據樣本? – 2011-03-10 15:22:47
在循環之外移動'EntireFile.ToLower()'將是一個合理的開始,但是您應該向探查器詢問最受傷的位置。如果你證明了樣本數據和一個完整的工作程序,有人可能有時間玩它。 – 2011-03-10 15:25:56
它是一個Nemo 440轉儲文件,但我不想最初發布它,因爲它可能會產生關於反編譯的討論... – alex 2011-03-10 15:26:56