MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testUnorderedSet

Method testUnorderedSet

test/IECore/MurmurHashTest.cpp:50–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48{
49
50 void testUnorderedSet()
51 {
52 std::unordered_set< IECore::MurmurHash > set;
53 for( size_t i = 0; i < 1000000; i++ )
54 {
55 IECore::MurmurHash h;
56 h.append( i );
57 set.insert( h );
58 }
59
60 BOOST_CHECK( set.size() == 1000000 );
61
62 size_t maxBucketOccupancy = 0;
63 for( size_t i = 0; i < set.bucket_count(); i++ )
64 {
65 maxBucketOccupancy = std::max( maxBucketOccupancy, set.bucket_size( i ) );
66 }
67
68 // If our hash function is good, then there shouldn't be any bucket that gets way too
69 // many elements in it - currently, I'm seeing a max occupancy of 8.
70 BOOST_CHECK( maxBucketOccupancy < 16 );
71 }
72};
73
74

Callers

nothing calls this directly

Calls 3

appendMethod · 0.80
insertMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected