1515// Generates probe length statistics for many combinations of key types and key
1616// distributions, all using the default hash function for swisstable.
1717
18+ #include < algorithm>
19+ #include < cstddef>
20+ #include < cstdint>
21+ #include < limits>
1822#include < memory>
1923#include < regex> // NOLINT
24+ #include < string>
25+ #include < utility>
2026#include < vector>
2127
2228#include " absl/base/no_destructor.h"
@@ -227,24 +233,6 @@ Ptr<Align>* MakePtr(uintptr_t v) {
227233 return reinterpret_cast <Ptr<Align>*>(v);
228234}
229235
230- struct IntIdentity {
231- uint64_t i;
232- friend bool operator ==(IntIdentity a, IntIdentity b) { return a.i == b.i ; }
233- IntIdentity operator ++(int ) { return IntIdentity{i++}; }
234- };
235-
236- template <int Align>
237- struct PtrIdentity {
238- explicit PtrIdentity (uintptr_t val = PointerForAlignment<Align>()) : i(val) {}
239- uintptr_t i;
240- friend bool operator ==(PtrIdentity a, PtrIdentity b) { return a.i == b.i ; }
241- PtrIdentity operator ++(int ) {
242- PtrIdentity p (i);
243- i += Align;
244- return p;
245- }
246- };
247-
248236enum class StringSize { kSmall , kMedium , kLarge , kExtraLarge };
249237constexpr char kStringFormat [] = " %s/name-%07d-of-9999999.txt" ;
250238
@@ -270,20 +258,6 @@ struct String {
270258 }
271259};
272260
273- template <>
274- struct DefaultHash <IntIdentity> {
275- struct type {
276- size_t operator ()(IntIdentity t) const { return t.i ; }
277- };
278- };
279-
280- template <int Align>
281- struct DefaultHash <PtrIdentity<Align>> {
282- struct type {
283- size_t operator ()(PtrIdentity<Align> t) const { return t.i ; }
284- };
285- };
286-
287261template <class T >
288262struct Sequential {
289263 T operator ()() const { return current++; }
@@ -389,20 +363,6 @@ struct Random<Ptr<Align>*, Dist> {
389363 }
390364};
391365
392- template <class Dist >
393- struct Random <IntIdentity, Dist> {
394- IntIdentity operator ()() const {
395- return IntIdentity{Random<uint64_t , Dist>{}()};
396- }
397- };
398-
399- template <class Dist , int Align>
400- struct Random <PtrIdentity<Align>, Dist> {
401- PtrIdentity<Align> operator ()() const {
402- return PtrIdentity<Align>{Random<uintptr_t , Dist>{}() * Align};
403- }
404- };
405-
406366template <class Dist , StringSize size>
407367struct Random <String<size>, Dist> {
408368 std::string operator ()() const {
@@ -423,18 +383,12 @@ std::string Name();
423383
424384std::string Name (uint32_t *) { return " u32" ; }
425385std::string Name (uint64_t *) { return " u64" ; }
426- std::string Name (IntIdentity*) { return " IntIdentity" ; }
427386
428387template <int Align>
429388std::string Name (Ptr<Align>**) {
430389 return absl::StrCat (" Ptr" , Align);
431390}
432391
433- template <int Align>
434- std::string Name (PtrIdentity<Align>*) {
435- return absl::StrCat (" PtrIdentity" , Align);
436- }
437-
438392template <StringSize size>
439393std::string Name (String<size>*) {
440394 switch (size) {
@@ -558,15 +512,10 @@ int main(int argc, char** argv) {
558512
559513 std::vector<Result> results;
560514 RunForType<uint64_t >(results);
561- RunForType<IntIdentity>(results);
562515 RunForType<Ptr<8 >*>(results);
563516 RunForType<Ptr<16 >*>(results);
564517 RunForType<Ptr<32 >*>(results);
565518 RunForType<Ptr<64 >*>(results);
566- RunForType<PtrIdentity<8 >>(results);
567- RunForType<PtrIdentity<16 >>(results);
568- RunForType<PtrIdentity<32 >>(results);
569- RunForType<PtrIdentity<64 >>(results);
570519 RunForType<std::pair<uint32_t , uint32_t >>(results);
571520 RunForType<String<StringSize::kSmall >>(results);
572521 RunForType<String<StringSize::kMedium >>(results);
0 commit comments