比较三种ordered set的性能

1 · Jia Yuehua · May 14, 2023, 1:37 a.m.
标准库提供了有序的std::set,folly中新增了两种有序set,sorted_vector_set和heap_vector_set。我们比较下它们的查找和插入的性能。 benchmark代码: #include <algorithm> #include <functional> #include <vector> #include <folly/Benchmark.h> #include <vector> #include <set> #include <folly/sorted_vector_types.h> #include <folly/container/heap_vector_types.h> #include <folly/Random.h> static inline constexpr int N=1000000; BENCHMARK_DRAW_LINE(); BENCHMARK(set_search, n) { folly::BenchmarkSuspender s; folly::Random::DefaultGenerator rng; rng....