我为制药公司开发了CRM。在创建报告时,我得到了6000-8000个医生记录。我已经做了一些计算。
为此,我已经在我得到的记录列表中定义了一个for循环。还有内环。所以我的迭代次数正在增加。大约6000 * 16 * 2 = 3,12,000。
显然需要花费很多时间。所以请帮我缩小范围。
答案 0 :(得分:0)
你看过并行处理吗?只要您的记录不是很大,就不会有8000条记录。
public class Doctor
{
public int Id;
public string Name;
public int ImportantValue;
}
class Program
{
static void Main(string[] args)
{
var doctors = Builder<Doctor>.CreateListOfSize(8000).Build();
Parallel.ForEach(doctors, doctor => {
// Inner loop 1
for(int i = 0; i < 16; i++)
{
// do stuff in inner loop 1
}
// Inner loop 2
for (int i = 0; i < 16; i++)
{
// do stuff in inner loop 1
}
});
}
利用 Parallel.For(),您可以通过将列表中的每个对象传递给单独的线程来显着加快处理速度。
正如评论者已经说过的那样,如果不知道你现在在做什么,就不可能更具体地回答你的问题。您可能还需要在代码中执行一些任务/等待内容以显着加快速度。
底线:8000条记录中的任何内容在今天的计算机中都不是很多:)