From fbb33ca998e42574eee06761307cb65eda1644c2 Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Tue, 11 Feb 2025 15:23:33 +0100 Subject: [PATCH 1/4] improve table to describe backend properties --- src/lib.rs | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 400b400..02770f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,26 +81,31 @@ //! //! The `string_interner` crate provides different backends with different strengths. //! The table below compactly shows when to use which backend according to the following -//! performance characteristics. -//! -//! - **Fill:** Efficiency of filling an empty string interner. -//! - **Resolve:** Efficiency of resolving a symbol of an interned string. -//! - **Allocations:** The number of allocations performed by the backend. -//! - **Footprint:** The total heap memory consumed by the backend. -//! - **Iteration:** Efficiency of iterating over the interned strings. -//! - **Contiguous:** True if the returned symbols have contiguous values. -//! - **Stable Refs:** If the string references are stable after the first insertion. -//! -//! | **Property** | **BucketBackend** | **StringBackend** | **BufferBackend** | -//! |:-------------|:-----------------:|:-----------------:|:-----------------:| -//! | **Fill** | ok | good | best | -//! | **Resolve** | best | good | bad | -//! | Allocations | ok | good | best | -//! | Footprint | ok | good | best | -//! | Iteration | best | good | bad | -//! | | | | | -//! | Contiguous | yes | yes | no | -//! | Stable Refs | yes | no | no | +//! performance characteristics and properties. +//! +//! | **Property** | **BucketBackend** | **StringBackend** | **BufferBackend** | | Explanation | +//! |:-------------|:-----------------:|:-----------------:|:-----------------:|:--|:--| +//! | Fill | 🤷 | 👍 | ⭐ | | Efficiency of filling an empty string interner. | +//! | Fill Duplicates | 1) | 1) | 1) | | Efficiency of filling a string interner with strings that are already interned. | +//! | Resolve | ⭐ | 👍 | 👎 | | Efficiency of resolving a symbol of an interned string. | +//! | Allocations | 🤷 | 👍 | ⭐ | | The number of allocations performed by the backend. | +//! | Footprint | 🤷 | 👍 | ⭐ | | The total heap memory consumed by the backend. | +//! | Iteration | ⭐ | 👍 | 👎 | | Efficiency of iterating over the interned strings. | +//! | | | | | | | +//! | Contiguous | ✅ | ✅ | ❌ | | The returned symbols have contiguous values. | +//! | Stable Refs | ✅ | ❌ | ❌ | | The interned strings have stable references. | +//! | Static Strings | ✅ | ❌ | ❌ | | Allows to intern `&'static str` without heap allocations. | +//! +//! 1. Performance of interning pre-interned string is the same for all backends since +//! this is implemented in the `StringInterner` front-end via a `HashMap` query for +//! all `StringInterner` instances. +//! +//! ### Legend +//! +//! - ⭐: best performance in cathegory +//! - 👍: good performance +//! - 🤷: okay performance +//! - 👎: bad performance //! //! ## When to use which backend? //! From 697c0eeea81943f4f72c35a13d0065c36c2b8c8f Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Tue, 11 Feb 2025 15:24:37 +0100 Subject: [PATCH 2/4] apply rustfmt --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 02770f3..83d762c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,13 +95,13 @@ //! | Contiguous | ✅ | ✅ | ❌ | | The returned symbols have contiguous values. | //! | Stable Refs | ✅ | ❌ | ❌ | | The interned strings have stable references. | //! | Static Strings | ✅ | ❌ | ❌ | | Allows to intern `&'static str` without heap allocations. | -//! +//! //! 1. Performance of interning pre-interned string is the same for all backends since //! this is implemented in the `StringInterner` front-end via a `HashMap` query for //! all `StringInterner` instances. -//! +//! //! ### Legend -//! +//! //! - ⭐: best performance in cathegory //! - 👍: good performance //! - 🤷: okay performance From 27976f11fd00d258071b995f8e6c6b74d8fab090 Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Tue, 11 Feb 2025 15:32:08 +0100 Subject: [PATCH 3/4] improve legend table --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 83d762c..dfc9205 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,10 +102,9 @@ //! //! ### Legend //! -//! - ⭐: best performance in cathegory -//! - 👍: good performance -//! - 🤷: okay performance -//! - 👎: bad performance +//! | ⭐ | **best performance** | | 👍 | **good performance** | +//! |-|-|-|-|-| +//! | 🤷 | **okay performance** | | 👎 | **bad performance** | //! //! ## When to use which backend? //! From 23796f831f596d6465d35c18bdcfa433a6fee985 Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Tue, 11 Feb 2025 15:36:34 +0100 Subject: [PATCH 4/4] simplify legend further --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dfc9205..48a398c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,9 +102,8 @@ //! //! ### Legend //! -//! | ⭐ | **best performance** | | 👍 | **good performance** | -//! |-|-|-|-|-| -//! | 🤷 | **okay performance** | | 👎 | **bad performance** | +//! | ⭐ | **best performance** | 👍 | **good performance** | 🤷 | **okay performance** | 👎 | **bad performance** | +//! |-|-|-|-|-|-|-|-| //! //! ## When to use which backend? //!