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

后端 未结 11 560
无人及你
无人及你 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:34

    My guess is that locks don't experience much contention. I would recommend reading following article: Java theory and practice: Anatomy of a flawed microbenchmark. The article discusses a lock microbenchmark. As stated in the article there are a lot of things to take into consideration in this kind of situations.

提交回复
热议问题