ConcurrentHashMap vs ConcurrentSkipListMap性能對比

Java CPU 技術 心藍說JAVA 心藍說JAVA 2017-09-18

在講ConcurrentSkipListMap的時候,我們做了一個和ConcurrentHashMap的性能對比,由於我的電腦配置比較垃圾,還是5年前買的便宜貨,最大的線程數我只做了100個的測試,大家可以自己再去做一下測試和對比

什麼時候使用ConcurrentSkipListMap呢?

  • ConcurrentSkipListMap guaranteesO(log(n))time complexityperformancefor most of its operations like firstKey, firstEntry, lastEntry, pollFirstEntry, pollLastEntry, etc.

  • ConcurrentSkipListMap does not allow to modify theconcurrent threadcount.

  • ConcurrentSkipListMap is both a NavigableMap and aSortedMap(like Java Set).

  • ConcurrentSkipListMap is a SkipList.

我的對比方法,每一次測試進行五組,然後取五組的對比平均值

ConcurrentHashMap vs ConcurrentSkipListMap性能對比

對比代碼實現

對比的結果報表

ConcurrentHashMap vs ConcurrentSkipListMap性能對比

對比結果-線性圖

ConcurrentHashMap vs ConcurrentSkipListMap性能對比

對比結果-柱狀圖

課程的教學視頻都已經上傳,大概在75講的部分中,大家到時候自己做一下測試,不同的硬件配置(CPU/內存),結果可能有些差別,我希望大家再增多一些維度去對比

ConcurrentHashMap vs ConcurrentSkipListMap性能對比

視頻下載地址和獲取方法

注意,我測試的數據量是50萬,線程最大個數為100個,進行了十批測試,每一批有五組測試,大家可以自行豐富對比維度~

相關推薦

推薦中...