일부 ddump 파일을 구문 분석하려고하는데 알고리즘 속도를 높이는 데 도움이 될 수 있습니까?
각 루프마다 216ms가 걸립니다 !! 그건 너무 비싸다. 루프 당 약 40 ~ 50 밀리 초 정도가 필요합니다. 어쩌면 RegExp를 사용했을까요? 어떤 도움을 크게 감상 할 수구문 분석 알고리즘 속도 향상
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);
}
:
여기 내 algrithm입니다.
덤프의 형식을 알고하는 동안의 끝에서 수행 할 파일이 있습니다. 파일 크기는 얼마입니까? 공유 할 수있는 데이터의 샘플이 있습니까? –
루프 외부에서 'EntireFile.ToLower() '를 이동하는 것이 합리적 일 수 있지만, 가장 많이 손상된 프로파일 러에게 요청해야합니다. 샘플 데이터와 완벽한 작업 프로그램을 입증 한 사람은 누군가와 함께 게임 할 시간을 가질 수 있습니다. –
그것의 Nemo 440 덤프 파일,하지만 난 원래 그것을 디 컴파일에 관한 morallical 토론을 생산할 수 있기 때문에 그것을 게시하고 싶지 않았어 ... – alex