25 #include <unordered_map> 26 #include <unordered_set> 42 using std::unordered_map;
43 using std::unordered_set;
46 static map<string, int>
m;
50 static unordered_map<string, int>
um;
52 static unordered_set<string>
us;
56 "1234567890abcdefghijklmnopqrstuvwxyz"};
58 #if !defined(FOLLY_HAVE_COMPARE_EQUIVALENT) && _LIBCPP_VERSION >= 3400 59 #define FOLLY_HAVE_COMPARE_EQUIVALENT 1 62 #if !defined(FOLLY_HAVE_COMPARE_EQUIVALENT) && __GNUC__ >= 5 63 #define FOLLY_HAVE_COMPARE_EQUIVALENT 1 66 #if FOLLY_HAVE_COMPARE_EQUIVALENT 67 static map<string, int, std::less<void>> m_equiv;
68 static set<string, std::less<void>> s_equiv;
72 for (
int i = 0;
i < 1000; ++
i) {
73 auto iStr = to<string>(
i);
77 m.insert(make_pair(
lookup, 0));
80 skm = decltype(skm){m.begin(), m.end()};
81 um = decltype(um){m.begin(), m.end()};
82 skum = decltype(skum){m.begin(), m.end()};
84 sks = decltype(
sks){s.begin(), s.end()};
85 us = decltype(us){s.begin(), s.end()};
86 skus = decltype(
skus){s.begin(), s.end()};
87 #if FOLLY_HAVE_COMPARE_EQUIVALENT 88 m_equiv = decltype(m_equiv){m.begin(), m.end()};
89 s_equiv = decltype(s_equiv){s.begin(), s.end()};
101 #if FOLLY_HAVE_COMPARE_EQUIVALENT 151 BENCHMARK(std_unordered_map_benchmark_erase_emplace_native) {
168 skum.emplace(
lookup, 123);
181 #if FOLLY_HAVE_COMPARE_EQUIVALENT 231 BENCHMARK(std_unordered_set_benchmark_erase_emplace_native) {
252 gflags::ParseCommandLineFlags(&argc, &argv,
true);
static void initBenchmarks()
static StringKeyedUnorderedMap< int > skum
BENCHMARK_RELATIVE(std_map_benchmark_find_cross)
BasicStringKeyedUnorderedSet<> StringKeyedUnorderedSet
StringKeyedSetBase<> StringKeyedSet
std::pair< iterator, bool > emplace(StringPiece key, Args &&...args)
static unordered_map< string, int > um
std::enable_if< detail::is_chrono_conversion< Tgt, Src >::value, Tgt >::type to(const Src &value)
static StringKeyedSet sks
static StringKeyedMap< int > skm
int main(int argc, char **argv)
static map< string, int > m
static StringKeyedUnorderedSet skus
static const std::string lookup
static const folly::StringPiece lookupPiece
BENCHMARK(std_map_benchmark_find_native)
Range< const char * > StringPiece
iterator erase(const_iterator position)
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
static unordered_set< string > us