Using 'AsParallel()' / 'Parallel.ForEach()' guidelines?

前端 未结 4 1858
说谎
说谎 2021-01-30 20:52

Looking for a little advice on leveraging AsParallel() or Parallel.ForEach() to speed this up.

See the method I\'ve got (simplified/bastardized

4条回答
  •  粉色の甜心
    2021-01-30 21:21

    This seems like an inherently serial operation to me. All you're doing is looping through a list of strings and inserting them into another list. The parallelization libraries are going to do that, plus a bunch of threading and synchronization - it'd probably end up slower.

    Also, you should be using a HashSet if you don't want duplicates.

提交回复
热议问题