Why is ConcurrentBag so slow in .Net (4.0)? Am I doing it wrong?

后端 未结 11 603
无人及你
无人及你 2020-12-08 04:05

Before I started a project, I wrote a simple test to compare the performance of ConcurrentBag from (System.Collections.Concurrent) relative to locking & lists. I am extr

11条回答
  •  一个人的身影
    2020-12-08 04:54

    It appears that ConcurrentBag is just slower than the other concurrent collections.

    I think it's an implementation problem- ANTS Profiler shows that it is gets bogged down in a couple of places - including an array copy.

    Using concurrent dictionary is thousands of times faster.

提交回复
热议问题