Mar*_*ayo 0 c# optimization performance list
我有一个遗留应用程序,曾经使用小(呃)数据集.
目前我们正在扩展它以运行更大的数据集(yay总是运行良好).
所以现在我有了这段代码. sValues是一个包含2100万(是)项目的清单.sProcessedStatus是一个匹配列表,表明我们是否要使用它(即不是-1或-2),如果我们是,我们将它们添加到groupSourceVals.但我们只添加唯一值,因此indexOf()检查.
for (int p = 0; p < sValues.Count; p++)
{
int currentProcessed = sProcessedStatus[p];
if ((!(currentProcessed == -1)) && (!(currentProcessed == -2)))
{
if (groupSourceVals.IndexOf(sValues[p]) == -1)
{
groupSourceVals.Add(sValues[p]);
}
}
else
{
Console.WriteLine("Dropping non-processed value " + sValues[p]);
}
}
Run Code Online (Sandbox Code Playgroud)
然而,在64位四核机器上,几天后它仍然严重运行.除了傻逼多线程之外,还有任何关于加速它的理论我都不知道了吗?IndexOf是否大幅减速,是否有更好的选择?