"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "benchmark/libponyrt/ds/hash.cc" between
ponyc-0.33.1.tar.gz and ponyc-0.33.2.tar.gz

About: Pony is an object-oriented, actor-model, capabilities-secure, high performance programming language.

hash.cc  (ponyc-0.33.1):hash.cc  (ponyc-0.33.2)
skipping to change at line 87 skipping to change at line 87
void HashMapBench::delete_elements(size_t del_pct, size_t count) void HashMapBench::delete_elements(size_t del_pct, size_t count)
{ {
hash_elem_t* e1 = get_element(); hash_elem_t* e1 = get_element();
size_t del_count = (del_pct * count) / 100; size_t del_count = (del_pct * count) / 100;
size_t final_count = (del_count > count) ? 0 : count - del_count; size_t final_count = (del_count > count) ? 0 : count - del_count;
// delete random items until map size is as small as required // delete random items until map size is as small as required
while(testmap_size(&_map) > final_count) while(testmap_size(&_map) > final_count)
{ {
e1->key = rand() % count; e1->key = (size_t)rand() % count;
hash_elem_t* d = testmap_remove(&_map, e1); hash_elem_t* d = testmap_remove(&_map, e1);
if(d != NULL) if(d != NULL)
free_elem(d); free_elem(d);
} }
free_elem(e1); free_elem(e1);
} }
hash_elem_t* HashMapBench::get_element() hash_elem_t* HashMapBench::get_element()
{ {
skipping to change at line 135 skipping to change at line 135
if(testmap_size(&_map) != (size_t)(old_size/2)) if(testmap_size(&_map) != (size_t)(old_size/2))
{ {
st.SkipWithError("Map should be exactly half filled!"); st.SkipWithError("Map should be exactly half filled!");
break; // Needed to skip the rest of the iteration. break; // Needed to skip the rest of the iteration.
} }
st.ResumeTiming(); st.ResumeTiming();
// destroy map // destroy map
testmap_destroy(&_map); testmap_destroy(&_map);
} }
testmap_init(&_map, sz); testmap_init(&_map, sz);
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
} }
BENCHMARK_REGISTER_F(HashMapBench, HashDestroy$)->RangeMultiplier(2)->Ranges({{1 , 32<<10}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashDestroy$)->RangeMultiplier(2)->Ranges({{1 , 32<<10}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashResize$)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashResize$)(benchmark::State& st) {
size_t old_size = 0; size_t old_size = 0;
size_t count = static_cast<size_t>(st.range(0)); size_t count = static_cast<size_t>(st.range(0));
while (st.KeepRunning()) { while (st.KeepRunning()) {
st.PauseTiming(); st.PauseTiming();
if(_map.contents.size == old_size) if(_map.contents.size == old_size)
skipping to change at line 167 skipping to change at line 167
if(testmap_size(&_map) != (size_t)(old_size/2)) if(testmap_size(&_map) != (size_t)(old_size/2))
{ {
st.SkipWithError("Map should be exactly half filled!"); st.SkipWithError("Map should be exactly half filled!");
break; // Needed to skip the rest of the iteration. break; // Needed to skip the rest of the iteration.
} }
hash_elem_t* curr = get_element(); hash_elem_t* curr = get_element();
curr->key = (old_size/2) + 1; curr->key = (old_size/2) + 1;
st.ResumeTiming(); st.ResumeTiming();
testmap_put(&_map, curr); testmap_put(&_map, curr);
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
} }
BENCHMARK_REGISTER_F(HashMapBench, HashResize$)->RangeMultiplier(2)->Ranges({{1, 32<<10}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashResize$)->RangeMultiplier(2)->Ranges({{1, 32<<10}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashNext)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashNext)(benchmark::State& st) {
while (st.KeepRunning()) { while (st.KeepRunning()) {
size_t ind = HASHMAP_UNKNOWN; size_t ind = HASHMAP_UNKNOWN;
for(size_t i = 0; i < testmap_size(&_map); i++) { for(size_t i = 0; i < testmap_size(&_map); i++) {
hash_elem_t* n = testmap_next(&_map, &ind); hash_elem_t* n = testmap_next(&_map, &ind);
if(n == NULL) if(n == NULL)
skipping to change at line 190 skipping to change at line 190
break; // Needed to skip the rest of the iteration. break; // Needed to skip the rest of the iteration.
} }
} }
hash_elem_t* n = testmap_next(&_map, &ind); hash_elem_t* n = testmap_next(&_map, &ind);
if(n != NULL) if(n != NULL)
{ {
st.SkipWithError("Item should be NULL!"); st.SkipWithError("Item should be NULL!");
break; // Needed to skip the rest of the iteration. break; // Needed to skip the rest of the iteration.
} }
} }
st.SetItemsProcessed(st.iterations() * (testmap_size(&_map) + 1)); st.SetItemsProcessed((int64_t)(st.iterations() * (testmap_size(&_map) + 1)));
} }
BENCHMARK_REGISTER_F(HashMapBench, HashNext)->RangeMultiplier(2)->Ranges({{1, 32 <<10}, {1, 32}}); BENCHMARK_REGISTER_F(HashMapBench, HashNext)->RangeMultiplier(2)->Ranges({{1, 32 <<10}, {1, 32}});
BENCHMARK_REGISTER_F(HashMapBench, HashNext)->RangeMultiplier(2)->Ranges({{1, 1} , {1, 32<<10}}); BENCHMARK_REGISTER_F(HashMapBench, HashNext)->RangeMultiplier(2)->Ranges({{1, 1} , {1, 32<<10}});
BENCHMARK_DEFINE_F(HashMapBench, HashPut)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashPut)(benchmark::State& st) {
hash_elem_t* curr = get_element(); hash_elem_t* curr = get_element();
size_t i = 0; size_t i = 0;
size_t mod = static_cast<size_t>(st.range(0)); size_t mod = static_cast<size_t>(st.range(0));
while (st.KeepRunning()) { while (st.KeepRunning()) {
curr->key = i & mod; curr->key = i & mod;
// put item // put item
testmap_put(&_map, curr); testmap_put(&_map, curr);
i++; i++;
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
for(i = 0; i < _map.contents.size; i++) for(i = 0; i < _map.contents.size; i++)
testmap_clearindex(&_map, i); testmap_clearindex(&_map, i);
free_elem(curr); free_elem(curr);
} }
BENCHMARK_REGISTER_F(HashMapBench, HashPut)->RangeMultiplier(2)->Ranges({{32<<10 , 32<<10}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashPut)->RangeMultiplier(2)->Ranges({{32<<10 , 32<<10}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashPutResize)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashPutResize)(benchmark::State& st) {
hash_elem_t* curr = get_element(); hash_elem_t* curr = get_element();
size_t i = 1; size_t i = 1;
while (st.KeepRunning()) { while (st.KeepRunning()) {
curr->key = i; curr->key = i;
// put item // put item
testmap_put(&_map, curr); testmap_put(&_map, curr);
i++; i++;
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
for(i = 0; i < _map.contents.size; i++) for(i = 0; i < _map.contents.size; i++)
testmap_clearindex(&_map, i); testmap_clearindex(&_map, i);
free_elem(curr); free_elem(curr);
} }
BENCHMARK_REGISTER_F(HashMapBench, HashPutResize)->RangeMultiplier(2)->Ranges({{ 1, 1}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashPutResize)->RangeMultiplier(2)->Ranges({{ 1, 1}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashPutNew)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashPutNew)(benchmark::State& st) {
hash_elem_t* curr = NULL; hash_elem_t* curr = NULL;
size_t i = 0; size_t i = 0;
skipping to change at line 248 skipping to change at line 248
if(curr == NULL) if(curr == NULL)
curr = get_element(); curr = get_element();
curr->key = i & mod; curr->key = i & mod;
// put item // put item
curr = testmap_put(&_map, curr); curr = testmap_put(&_map, curr);
i++; i++;
} }
if(curr != NULL) if(curr != NULL)
free_elem(curr); free_elem(curr);
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
} }
BENCHMARK_REGISTER_F(HashMapBench, HashPutNew)->RangeMultiplier(2)->Ranges({{32< <10, 32<<10}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashPutNew)->RangeMultiplier(2)->Ranges({{32< <10, 32<<10}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashPutNewResize)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashPutNewResize)(benchmark::State& st) {
hash_elem_t* curr = NULL; hash_elem_t* curr = NULL;
size_t i = 1; size_t i = 1;
while (st.KeepRunning()) { while (st.KeepRunning()) {
curr = get_element(); curr = get_element();
curr->key = i; curr->key = i;
// put item // put item
testmap_put(&_map, curr); testmap_put(&_map, curr);
i++; i++;
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
} }
BENCHMARK_REGISTER_F(HashMapBench, HashPutNewResize)->RangeMultiplier(2)->Ranges ({{1, 1}, {0, 0}}); BENCHMARK_REGISTER_F(HashMapBench, HashPutNewResize)->RangeMultiplier(2)->Ranges ({{1, 1}, {0, 0}});
BENCHMARK_DEFINE_F(HashMapBench, HashRemove$_)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashRemove$_)(benchmark::State& st) {
size_t sz = static_cast<size_t>(st.range(2)); size_t sz = static_cast<size_t>(st.range(2));
hash_elem_t* curr = get_element(); hash_elem_t* curr = get_element();
hash_elem_t** a = hash_elem_t** a =
(hash_elem_t**)ponyint_pool_alloc_size(sz * sizeof(hash_elem_t*)); (hash_elem_t**)ponyint_pool_alloc_size(sz * sizeof(hash_elem_t*));
for(size_t i = 0; i < sz; i++) for(size_t i = 0; i < sz; i++)
skipping to change at line 291 skipping to change at line 291
for(size_t i = 0; i < sz; i++) for(size_t i = 0; i < sz; i++)
testmap_put(&_map, a[i]); testmap_put(&_map, a[i]);
st.ResumeTiming(); st.ResumeTiming();
for(size_t i = 0; i < sz; i++) for(size_t i = 0; i < sz; i++)
{ {
curr->key = i; curr->key = i;
// remove item // remove item
testmap_remove(&_map, curr); testmap_remove(&_map, curr);
} }
} }
st.SetItemsProcessed(st.iterations() * sz); st.SetItemsProcessed((int64_t)(st.iterations() * sz));
for(size_t i = 0; i < sz; i++) for(size_t i = 0; i < sz; i++)
free_elem(a[i]); free_elem(a[i]);
free_elem(curr); free_elem(curr);
ponyint_pool_free_size(sz, a); ponyint_pool_free_size(sz, a);
} }
BENCHMARK_REGISTER_F(HashMapBench, HashRemove$_)->RangeMultiplier(2)->Ranges({{3 2<<10, 32<<10}, {0, 0}, {1<<10, 64<<10}}); BENCHMARK_REGISTER_F(HashMapBench, HashRemove$_)->RangeMultiplier(2)->Ranges({{3 2<<10, 32<<10}, {0, 0}, {1<<10, 64<<10}});
BENCHMARK_DEFINE_F(HashMapBench, HashSearch)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashSearch)(benchmark::State& st) {
hash_elem_t* e1 = get_element(); hash_elem_t* e1 = get_element();
skipping to change at line 317 skipping to change at line 317
if(st.range(2) == 0) { if(st.range(2) == 0) {
for(size_t i = 0; i < map_count; i++) { for(size_t i = 0; i < map_count; i++) {
hash_elem_t* n = testmap_next(&_map, &index); hash_elem_t* n = testmap_next(&_map, &index);
if(n != NULL) { if(n != NULL) {
a[i] = n->key; a[i] = n->key;
} }
} }
size_t t = 0; size_t t = 0;
size_t r = 0; size_t r = 0;
for(size_t i = 0; i < map_count; i++) { for(size_t i = 0; i < map_count; i++) {
r = rand() & map_count_mask; r = (size_t)rand() & map_count_mask;
t = a[r]; t = a[r];
a[r] = a[i]; a[r] = a[i];
a[i] = t; a[i] = t;
} }
} else { } else {
for(size_t i = 0; i < map_count; i++) { for(size_t i = 0; i < map_count; i++) {
a[i] = rand() + incr; a[i] = (size_t)rand() + incr;
} }
} }
index = HASHMAP_UNKNOWN; index = HASHMAP_UNKNOWN;
size_t j = 0; size_t j = 0;
while (st.KeepRunning()) { while (st.KeepRunning()) {
e1->key = a[j & map_count_mask]; e1->key = a[j & map_count_mask];
testmap_get(&_map, e1, &index); testmap_get(&_map, e1, &index);
j++; j++;
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
ponyint_pool_free_size(map_count, a); ponyint_pool_free_size(map_count, a);
free_elem(e1); free_elem(e1);
e1 = nullptr; e1 = nullptr;
} }
BENCHMARK_REGISTER_F(HashMapBench, HashSearch)->RangeMultiplier(2)->Ranges({{1, 1}, {1<<10, 32<<10}, {0, 1}}); BENCHMARK_REGISTER_F(HashMapBench, HashSearch)->RangeMultiplier(2)->Ranges({{1, 1}, {1<<10, 32<<10}, {0, 1}});
BENCHMARK_DEFINE_F(HashMapBench, HashSearchDeletes)(benchmark::State& st) { BENCHMARK_DEFINE_F(HashMapBench, HashSearchDeletes)(benchmark::State& st) {
size_t count = static_cast<size_t>(st.range(1)); size_t count = static_cast<size_t>(st.range(1));
// range(2) == % of items to delete at random // range(2) == % of items to delete at random
skipping to change at line 381 skipping to change at line 381
a = (size_t*)ponyint_pool_alloc_size(array_size * sizeof(size_t)); a = (size_t*)ponyint_pool_alloc_size(array_size * sizeof(size_t));
size_t ind = HASHMAP_UNKNOWN; size_t ind = HASHMAP_UNKNOWN;
if(st.range(3) == 0) { if(st.range(3) == 0) {
for(size_t i = 0; i < array_size; i++) { for(size_t i = 0; i < array_size; i++) {
if(i < map_count) { if(i < map_count) {
hash_elem_t* n = testmap_next(&_map, &ind); hash_elem_t* n = testmap_next(&_map, &ind);
if(n != NULL) { if(n != NULL) {
a[i] = n->key; a[i] = n->key;
} }
} else { } else {
a[i] = a[rand() % map_count]; a[i] = a[(size_t)rand() % map_count];
} }
} }
size_t t = 0; size_t t = 0;
size_t r = 0; size_t r = 0;
for(size_t i = 0; i < array_size; i++) { for(size_t i = 0; i < array_size; i++) {
r = rand() & array_size_mask; r = (size_t)rand() & array_size_mask;
t = a[r]; t = a[r];
a[r] = a[i]; a[r] = a[i];
a[i] = t; a[i] = t;
} }
} else { } else {
for(size_t i = 0; i < array_size; i++) { for(size_t i = 0; i < array_size; i++) {
a[i] = rand() + count; a[i] = (size_t)rand() + count;
} }
} }
ind = HASHMAP_UNKNOWN; ind = HASHMAP_UNKNOWN;
size_t j = 0; size_t j = 0;
while (st.KeepRunning()) { while (st.KeepRunning()) {
e1->key = a[j & array_size_mask]; e1->key = a[j & array_size_mask];
testmap_get(&_map, e1, &ind); testmap_get(&_map, e1, &ind);
j++; j++;
} }
st.SetItemsProcessed(st.iterations()); st.SetItemsProcessed((int64_t)st.iterations());
ponyint_pool_free_size(array_size, a); ponyint_pool_free_size(array_size, a);
free_elem(e1); free_elem(e1);
e1 = nullptr; e1 = nullptr;
} }
BENCHMARK_REGISTER_F(HashMapBench, HashSearchDeletes) BENCHMARK_REGISTER_F(HashMapBench, HashSearchDeletes)
->Args({1, 1<<10, 64, 0}) ->Args({1, 1<<10, 64, 0})
->Args({1, 2<<10, 64, 0}) ->Args({1, 2<<10, 64, 0})
->Args({1, 4<<10, 64, 0}) ->Args({1, 4<<10, 64, 0})
->Args({1, 8<<10, 64, 0}) ->Args({1, 8<<10, 64, 0})
 End of changes. 16 change blocks. 
16 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)