原贴: https://github.com/cpp2go/rbtree_skiplist_benchmark
go语言实现,红黑树用的nginx源码,跳跃表用的redis实现,map用go原生,sortlist自己实现,二分查找
go test -test.bench=.*
测试结果:
RbTree | SkipList | Map | SortList | |
New | 116 ns/op | 169 ns/op | 60.1 ns/op | 0.39 ns/op |
Insert | 1037 ns/op | 1577 ns/op | 98.5 ns/op | 130 ns/op |
Load | 90.1 ns/op | 148 ns/op | 50.2 ns/op | 91.6 ns/op |
range | 6600 ns/op | 7106 ns/op | 22141 ns/op | 352 ns/op |
goarch: amd64
Benchmark_RbTreeNew-16 20000000 116 ns/op
Benchmark_SkipListNew-16 10000000 169 ns/op
Benchmark_MapNew-16 30000000 60.1 ns/op
Benchmark_SortListNew-16 2000000000 0.39 ns/op
Benchmark_RbTreeInsert-16 2000000 1037 ns/op
Benchmark_SkipListInsert-16 1000000 1577 ns/op
Benchmark_MapInsert-16 20000000 98.5 ns/op
Benchmark_SortListInsert-16 10000000 130 ns/op
Benchmark_RbTreeLoad-16 20000000 90.1 ns/opBenchmark_SkipListLoad-16 10000000 148 ns/op
Benchmark_MapLoad-16 30000000 50.2 ns/op
Benchmark_SortListLoad-16 20000000 91.6 ns/op
Benchmark_RbTreeRange-16 300000 6600 ns/opBenchmark_SkipListRange-16 200000 7106 ns/op
Benchmark_MapRange-16 100000 22141 ns/op
Benchmark_SortListRange-16 5000000 352 ns/op
原作者结论: