Investigating benchmark u64 failures.

This commit is contained in:
Davi Reis 2012-04-22 02:41:43 +02:00
parent 334f5592ea
commit 8b1d7da028
2 changed files with 17 additions and 21 deletions

View File

@ -72,8 +72,13 @@ class BM_SearchUint64 : public SearchUint64Benchmark {
}
mymap_.rehash(mymap_.bucket_count());
// Double check if everything is all right
cerr << "Doing double check" << endl;
for (uint32_t i = 0; i < values_.size(); ++i) {
if (mymap_[values_[i]] != values_[i]) return false;
if (mymap_[values_[i]] != values_[i]) {
fprintf(stderr, "Looking for %u th key value %llu yielded %llu\n",
i ,values_[i], mymap_[values_[i]]);
return false;
}
}
return true;
}
@ -95,12 +100,14 @@ using namespace cxxmph;
int main(int argc, char** argv) {
srandom(4);
/*
Benchmark::Register(new BM_CreateUrls<mph_map<StringPiece, StringPiece>>("URLS100k"));
Benchmark::Register(new BM_CreateUrls<unordered_map<StringPiece, StringPiece>>("URLS100k"));
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0));
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0));
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
*/
Benchmark::Register(new BM_SearchUint64<mph_map<uint64_t, uint64_t>>);
Benchmark::Register(new BM_SearchUint64<unordered_map<uint64_t, uint64_t>>);
Benchmark::RunAll();

View File

@ -79,11 +79,10 @@ class mph_map {
inline const_iterator find(const key_type& k) const;
typedef int32_t my_int32_t; // help macros
inline int32_t index(const key_type& k) const;
inline int32_t index2(const key_type& k) const;
data_type& operator[](const key_type &k);
const data_type& operator[](const key_type &k) const;
size_type bucket_count() const { return index_.perfect_hash_size() + slack_.bucket_count(); }
size_type bucket_count() const { return index_.minimal_perfect_hash_size() + slack_.bucket_count(); }
void rehash(size_type nbuckets /*ignored*/);
protected: // mimicking STL implementation
@ -154,13 +153,13 @@ MPH_MAP_METHOD_DECL(void_type, pack)() {
make_iterator_first(begin()),
make_iterator_first(end()), size_);
if (!success) { exit(-1); }
vector<value_type> new_values(index_.perfect_hash_size());
vector<value_type> new_values(index_.minimal_perfect_hash_size());
new_values.reserve(new_values.size() * 2);
vector<bool> new_present(index_.perfect_hash_size(), false);
vector<bool> new_present(index_.minimal_perfect_hash_size(), false);
new_present.reserve(new_present.size() * 2);
for (iterator it = begin(), it_end = end(); it != it_end; ++it) {
size_type id = index_.perfect_hash(it->first);
assert(id < index_.perfect_hash_size());
size_type id = index_.minimal_perfect_hash(it->first);
assert(id < index_.minimal_perfect_hash_size());
assert(id < new_values.size());
new_values[id] = *it;
new_present[id] = true;
@ -211,21 +210,11 @@ MPH_MAP_INLINE_METHOD_DECL(iterator, find)(const key_type& k) {
return make_solid(&values_, &present_, vit);;
}
MPH_MAP_INLINE_METHOD_DECL(my_int32_t, index2)(const key_type& k) const {
if (__builtin_expect(index_.perfect_hash_size(), 1)) {
auto perfect_hash = index_.perfect_hash(k);
return perfect_hash;
}
return -1;
}
MPH_MAP_INLINE_METHOD_DECL(my_int32_t, index)(const key_type& k) const {
if (__builtin_expect(index_.perfect_hash_size(), 1)) {
auto perfect_hash = index_.perfect_hash(k);
if (__builtin_expect(present_[perfect_hash], true)) {
return perfect_hash;
if (__builtin_expect(index_.minimal_perfect_hash_size(), 1)) {
auto minimal_perfect_hash = index_.minimal_perfect_hash(k);
if (__builtin_expect(present_[minimal_perfect_hash], true)) {
return minimal_perfect_hash;
}
}
if (__builtin_expect(!slack_.empty(), 0)) {