Currently I am using LocalReport. Render to create PDF's for 90K records. Using normal 'for' loop, it takes around 4 hours to create PDF only. I have tried many options.
Tried with Parallel. Foreach with and without setting MaxDegreeOfParallelism with different values. There are 2 processors in my system. With setting MaxDegreeOfParallelism(MDP) =4, it is taking the time as normal 'for' loop. I thought increasing MDP to 40 will speed up the process. But didn't get expected results since it took 900 minutes.
Used
var list=List<Thread ()>;
foreach (var record in records) {
var thread = new Thread (=> GeneratePDF());
thread.Start();
list.Add(thread);
}
foreach(var listThreads in thread){
listThreads. Join();
}
I used the code above like that. But it ended up creating too many threads and took so longer time.
I need help in using Parallel. Foreach to speed up the process of creating PDF's for 90K records. Suggestions to change the code is also acceptable. Any help would be much appreciated.
Thanks
答案 0 :(得分:1)
我不知道任何pdf生成器,所以我只能假设在初始化和完成任务时会有很多开销。这就是我要做的事情:
查找开源pdf生成器。
让它生成一些单独的pdf文件 - 页眉,页脚等。
挖掘代码以找到页眉/页脚的位置并尝试解决它们以重用生成器状态而不会遍历整个过程。
尝试将存储状态的pdf与仅写入不同部分的生成器结合在一起。