Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
gmryuuko committed Jun 22, 2024
1 parent cf27b04 commit c9d9388
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,18 @@ impl<'de, T: Eq + Hash + Send + Sync + ?Sized + 'static + Deserialize<'de>> Dese

#[cfg(test)]
mod intern_tests {
use std::hash::Hash;

use super::Intern;
use super::{Borrow, Deref};
use std::hash::Hash;

#[cfg(feature = "deepsize")]
use super::INTERN_CONTAINERS;
#[cfg(feature = "deepsize")]
use crate::{boxedset::HashSet, deep_size_of_interned};
#[cfg(feature = "deepsize")]
use std::sync::Arc;

#[cfg(feature = "deepsize")]
use deepsize::{Context, DeepSizeOf};
#[cfg(feature = "deepsize")]
use std::sync::Arc;

#[test]
fn eq_string() {
Expand Down Expand Up @@ -614,16 +612,17 @@ mod intern_tests {
std::mem::size_of::<&'static ArcInside>() * m.capacity()
});

// 3 ArcInside has different hash values
INTERN_CONTAINERS.with(|m: &mut HashSet<&'static ArcInside>| assert_eq!(m.len(), 3));

let interned_size = deep_size_of_interned::<ArcInside>();

println!("string_size: {}", string_size);
println!("object_size: {}", object_size);
println!("set_size: {}", set_size);
println!("pointers_in_set_size: {}", pointers_in_set_size);
println!("interned_size: {}", interned_size);

// 3 ArcInside has different hash values
INTERN_CONTAINERS.with(|m: &mut HashSet<&'static ArcInside>| assert_eq!(m.len(), 3));

assert_eq!(
interned_size,
string_size + object_size + set_size + pointers_in_set_size
Expand Down

0 comments on commit c9d9388

Please sign in to comment.