Blender V4.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
5#include "BLI_hash_tables.hh"
6#include "BLI_string.h"
7
8#include <iostream>
9
10void blender::HashTableStats::print(const char *name) const
11{
12 std::cout << "Hash Table Stats: " << name << "\n";
13 std::cout << " Address: " << address_ << "\n";
14 std::cout << " Total Slots: " << capacity_ << "\n";
15 std::cout << " Occupied Slots: " << size_ << " (" << load_factor_ * 100.0f << " %)\n";
16 std::cout << " Removed Slots: " << removed_amount_ << " (" << removed_load_factor_ * 100.0f
17 << " %)\n";
18
19 char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
20 BLI_str_format_byte_unit(memory_size_str, size_in_bytes_, true);
21 std::cout << " Size: ~" << memory_size_str << "\n";
22 std::cout << " Size per Slot: " << size_per_element_ << " bytes\n";
23
24 std::cout << " Average Collisions: " << average_collisions_ << "\n";
25 for (int64_t collision_count : keys_by_collision_count_.index_range()) {
26 std::cout << " " << collision_count
27 << " Collisions: " << keys_by_collision_count_[collision_count] << "\n";
28 }
29}
#define BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE
Definition BLI_string.h:28
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)
Definition string.c:1192
void print(const char *name) const
IndexRange index_range() const
__int64 int64_t
Definition stdint.h:89