/** * Time and report the execution of one hash across the entire Dictionary * * \param [in] hindex index of the hash Collider to use */ void TimeOne (const int hindex) { // Hashing speed uint32_t reps = 100; Hasher h = m_hashes[hindex].m_hash; int start = clock (); for (std::vector<std::string>::const_iterator w = m_words.begin (); w != m_words.end(); ++w) { for (uint32_t i = 0; i < reps; ++i) { h.clear ().GetHash32 (*w); } } int stop = clock (); double delta = stop - start; double per = 1e9 * delta / (m_nphrases * reps * CLOCKS_PER_SEC); std::cout << std::left << std::setw (32) << m_hashes[hindex].GetName () << std::right << std::setw (10) << m_nphrases << std::setw (10) << reps << std::setw (10) << stop - start << std::setw (12) << per << std::endl; } // TimeOne ()
/** * Get the appropriate hash value * * \param [in] phrase the string to hash * \return the hash value, using the number of bits set in the constructor */ uint64_t GetHash (const std::string phrase) { m_hash.clear (); uint64_t h = 0; if (m_bits == Bits32) { h = m_hash.GetHash32 (phrase); } else { h = m_hash.GetHash64 (phrase); } return h; }