当我向上迁移时,我遇到了以下循环的性能问题。它最初是用 VS2003 编写的。这个循环在 VS2003 中运行大约需要 20 秒。在 VS2005、VS2008、VS2010 和 VS2012 中,同样的循环需要 5 个小时才能运行。没有代码更改,所有版本都在同一台 PC 上运行。在尝试在 Visual Studio 中向上迁移时,是否有人遇到过这样的性能问题?我已经在以下版本的 Visual Studio 中运行了这个循环,这是我的 h/mm/ss 格式的结果。
VS2003 VS2005 VS2008 VS2010 VS2012
0:00:20 9:50:15 20:15:02 8:42:08 4:58:09
//dstPrvTbleSeq has 114881 rows
//dstPrvTbl has 104070 rows
foreach (DataRow dr in drSeq)
{ // in query PrvLocID is selected as PrvID to match with extract requirements
DataRow[] drSelect = dstPrvTbl.Tables[0].Select("PrvID=" + dr["PrvID"].ToString() + " and TermDate is null");
if (drSelect.Length > 0)
{
dr.Delete();
}
else
{
//delete duplicate term record with different fee schedule, only the first sequence fee schedule should show up as term
DataRow[] drSelect2 = dstPrvTbl.Tables[0].Select("PrvID=" + dr["PrvID"].ToString() + " and TermDate is not null");
if (drSelect2.Length > 0)
{
if (dr["TermDate"].ToString() != "")//if a term record for provider location id is already there and a new term record for another plan code comes across then delete the new one from file
dr.Delete();
else if (sPrvFileName.Trim().ToUpper() == "NEPTUNE.TXT" || sPrvFileName.Trim().ToUpper() == "PROV.TXT") //if Neptune file then remove the previous old term record and keep the new active record
{
drSelect2[0].Delete();//delete the old term record for neptune file
dstPrvTbl.AcceptChanges();
}
}
}
}