Blender V5.3
hash_tables.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_hash_tables.hh"
10#include "BLI_string.hh"
11
12#include <iostream>
13
14namespace blender {
15
16void HashTableStats::print(const char *name) const
17{
18 std::cout << "Hash Table Stats: " << name << "\n";
19 std::cout << " Address: " << address_ << "\n";
20 std::cout << " Total Slots: " << capacity_ << "\n";
21 std::cout << " Occupied Slots: " << size_ << " (" << load_factor_ * 100.0f << " %)\n";
22 std::cout << " Removed Slots: " << removed_amount_ << " (" << removed_load_factor_ * 100.0f
23 << " %)\n";
24
25 char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
26 BLI_str_format_byte_unit(memory_size_str, size_in_bytes_, true);
27 std::cout << " Size: ~" << memory_size_str << "\n";
28 std::cout << " Size per Slot: " << size_per_element_ << " bytes\n";
29
30 std::cout << " Average Collisions: " << average_collisions_ << "\n";
31 for (int64_t collision_count : keys_by_collision_count_.index_range()) {
32 std::cout << " " << collision_count
33 << " Collisions: " << keys_by_collision_count_[collision_count] << "\n";
34 }
35}
36
37} // namespace blender
#define BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE
Definition BLI_string.hh:31
void print(const char *name) const
BMesh Iterators.
void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE], long long int bytes, bool base_10) ATTR_NONNULL(1)
__int64 int64_t
Definition BKE_text.h:90