├── .github ├── renovate.json5 └── workflows │ ├── audit.yml │ └── ci.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── benches ├── access.rs ├── clone.rs ├── fixture.rs ├── new.rs └── self_eq.rs ├── deny.toml ├── runs ├── 2022-03-25 │ ├── access │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ └── report │ │ └── index.html ├── 2022-03-30 │ ├── access │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── access_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ └── report │ │ └── index.html ├── 2023-08-16 │ ├── access │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── access_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ └── report │ │ └── index.html ├── 2023-08-17 │ ├── access │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── access_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── clone_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ ├── new_static │ │ └── report │ │ │ ├── index.html │ │ │ ├── lines.svg │ │ │ └── violin.svg │ └── report │ │ └── index.html └── 2023-10-10 │ ├── access │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── access_static │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── clone │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── clone_static │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── new │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── new_static │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ ├── self_eq │ └── report │ │ ├── index.html │ │ ├── lines.svg │ │ └── violin.svg │ └── self_eq_static │ └── report │ ├── index.html │ ├── lines.svg │ └── violin.svg └── src └── main.rs /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | schedule: [ 3 | 'before 5am on the first day of the month', 4 | ], 5 | semanticCommits: 'enabled', 6 | configMigration: true, 7 | dependencyDashboard: true, 8 | packageRules: [ 9 | // Goals: 10 | // - Rollup safe upgrades to reduce CI runner load 11 | // - Have lockfile and manifest in-sync 12 | { 13 | matchManagers: [ 14 | 'cargo', 15 | ], 16 | matchCurrentVersion: '>=0.1.0', 17 | matchUpdateTypes: [ 18 | 'patch', 19 | ], 20 | automerge: true, 21 | groupName: 'compatible', 22 | }, 23 | { 24 | matchManagers: [ 25 | 'cargo', 26 | ], 27 | matchCurrentVersion: '>=1.0.0', 28 | matchUpdateTypes: [ 29 | 'minor', 30 | ], 31 | automerge: true, 32 | groupName: 'compatible', 33 | }, 34 | ], 35 | } 36 | -------------------------------------------------------------------------------- /.github/workflows/audit.yml: -------------------------------------------------------------------------------- 1 | name: Security audit 2 | 3 | permissions: 4 | contents: read 5 | 6 | on: 7 | pull_request: 8 | paths: 9 | - '**/Cargo.toml' 10 | - '**/Cargo.lock' 11 | push: 12 | branches: 13 | - main 14 | 15 | env: 16 | RUST_BACKTRACE: 1 17 | CARGO_TERM_COLOR: always 18 | CLICOLOR: 1 19 | 20 | jobs: 21 | security_audit: 22 | permissions: 23 | issues: write # to create issues (actions-rs/audit-check) 24 | checks: write # to create check (actions-rs/audit-check) 25 | runs-on: ubuntu-latest 26 | # Prevent sudden announcement of a new advisory from failing ci: 27 | continue-on-error: true 28 | steps: 29 | - name: Checkout repository 30 | uses: actions/checkout@v4 31 | - uses: actions-rs/audit-check@v1 32 | with: 33 | token: ${{ secrets.GITHUB_TOKEN }} 34 | 35 | cargo_deny: 36 | permissions: 37 | issues: write # to create issues (actions-rs/audit-check) 38 | checks: write # to create check (actions-rs/audit-check) 39 | runs-on: ubuntu-latest 40 | strategy: 41 | matrix: 42 | checks: 43 | - bans sources 44 | steps: 45 | - uses: actions/checkout@v4 46 | - uses: EmbarkStudios/cargo-deny-action@v2 47 | with: 48 | command: check ${{ matrix.checks }} 49 | rust-version: stable 50 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | permissions: 4 | contents: read 5 | 6 | on: 7 | pull_request: 8 | push: 9 | branches: 10 | - main 11 | 12 | env: 13 | RUST_BACKTRACE: 1 14 | CARGO_TERM_COLOR: always 15 | CLICOLOR: 1 16 | 17 | jobs: 18 | smoke: 19 | name: Quick Check 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v4 24 | - name: Install Rust 25 | uses: dtolnay/rust-toolchain@stable 26 | with: 27 | toolchain: stable 28 | - uses: Swatinem/rust-cache@v2 29 | - name: Default features 30 | run: cargo check --workspace --all-targets 31 | rustfmt: 32 | name: rustfmt 33 | runs-on: ubuntu-latest 34 | steps: 35 | - name: Checkout repository 36 | uses: actions/checkout@v4 37 | - name: Install Rust 38 | uses: dtolnay/rust-toolchain@stable 39 | with: 40 | toolchain: stable 41 | components: rustfmt 42 | - uses: Swatinem/rust-cache@v2 43 | - name: Check formatting 44 | run: cargo fmt --all -- --check 45 | clippy: 46 | name: clippy 47 | runs-on: ubuntu-latest 48 | permissions: 49 | security-events: write # to upload sarif results 50 | steps: 51 | - name: Checkout repository 52 | uses: actions/checkout@v4 53 | - name: Install Rust 54 | uses: dtolnay/rust-toolchain@stable 55 | with: 56 | toolchain: stable 57 | components: clippy 58 | - uses: Swatinem/rust-cache@v2 59 | - name: Install SARIF tools 60 | run: cargo install clippy-sarif sarif-fmt 61 | - name: Check 62 | run: > 63 | cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated 64 | | clippy-sarif 65 | | tee clippy-results.sarif 66 | | sarif-fmt 67 | continue-on-error: true 68 | - name: Upload 69 | uses: github/codeql-action/upload-sarif@v3 70 | with: 71 | sarif_file: clippy-results.sarif 72 | wait-for-processing: true 73 | - name: Report status 74 | run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "string-benchmarks-rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | arcstr = "1.1.5" 9 | compact_str = "0.9" 10 | ecow = "0.2.2" 11 | flexstr = "0.9.2" 12 | hipstr = "0.8.0" 13 | imstr = "0.2.0" 14 | kstring = "2.0.0" 15 | smartstring = "1.0.1" 16 | 17 | [dev-dependencies] 18 | criterion = { version = "0.5.1", features = ["html_reports"] } 19 | 20 | [[bench]] 21 | name = "new" 22 | harness = false 23 | 24 | [[bench]] 25 | name = "clone" 26 | harness = false 27 | 28 | [[bench]] 29 | name = "access" 30 | harness = false 31 | 32 | [[bench]] 33 | name = "self_eq" 34 | harness = false 35 | 36 | [profile.release] 37 | debug = 1 38 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 The assert_cli Developers 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust String Benchmarks 2 | 3 | This repo tries to assess Rust string types. 4 | 5 | We currently compare: 6 | 7 | Name | Size | Heap | Inline | `&'static str` | Mutable | Unsafe | Notes 8 | ------------------------------------------------------|----------|-------|----------|----------------|---------|--------|----- 9 | `String` | 24 bytes | **Y** | \- | N | **Y** | \- | Universal 10 | `Cow<'static, str>` | 24 bytes | **Y** | \- | **Y** | N | \- | 11 | [`arcstr`](https://crates.io/crates/arcstr) | 8 bytes | ? | ? | ? | ? | ? | ? 12 | [`compact_str`](https://crates.io/crates/compact_str) | 24 bytes | **Y** | 24 bytes | **Y** | **Y** | **Y** (miri, proptest, fuzz) | Space optimized for `Option<_>` 13 | [`ecow`](https://crates.io/crates/ecow) | 16 bytes | **Y** | 15 bytes | N | **Y** | **Y** (miri) | O(1) clone unless mutated, Space optimized for `Option<_>` 14 | [`flexstr`](https://crates.io/crates/flexstr) | 24 bytes | **Y** | 22 bytes | **Y** | N | **Y** (miri) | O(1) clone 15 | [`hipstr`](https://crates.io/crates/hipstr) | 24 bytes | **Y** | 23 bytes | **Y** | **Y** | **Y** (miri) | O(1) clone, O(1) substring 16 | [`imstr`](https://crates.io/crates/imstr) | 24 bytes | ? | ? | ? | ? | ? | ? 17 | [`kstring`](https://crates.io/crates/kstring) | 24 bytes | **Y** | 15 bytes | **Y** | N | Optional (miri, proptest) | Optional O(1) clone, optional 22 byte small string, Ref/Cow API for preserving `&'static str` 18 | [`smartstring`](https://crates.io/crates/smartstring) | 24 bytes | **Y** | 23 bytes | N | **Y** | **Y** (miri, proptest, fuzz) | 19 | 20 | Suggestions: 21 | - Generally, `String` 22 | - If you deal mostly with string literals but want some flexibility (like 23 | [clap](https://github.com/clap-rs/clap/)), generally you'll want 24 | `Cow<'static, str`> 25 | - If a profiler says your strings are a problem: 26 | - Try different crates and settings for that crate out with a profiler 27 | - O(1) clones are important when doing a lot of clones. For one-off allocations, they are slower. 28 | - For short-lived programs, look into string interning 29 | 30 | Note: `smol_str` was removed [in favor of `ecow`](https://www.reddit.com/r/rust/comments/117ksvr/ecow_compact_cloneonwrite_vector_and_string/j9eh35d/) 31 | 32 | Terms: 33 | - Heap: will store strings in heap-allocated memory 34 | - Inline: will store small-enough strings on the stack 35 | 36 | # Results 37 | 38 | `new` summary: 39 | [![`new`](runs/2023-10-10/new/report/lines.svg)](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/new/report/index.html) 40 | 41 | See [more details](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/new/report/index.html) 42 | 43 | `clone` summary: 44 | [![`clone`](runs/2023-10-10/clone/report/lines.svg)](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/clone/report/index.html) 45 | 46 | See [more details](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/clone/report/index.html) 47 | 48 | `access` summary: 49 | [![`access`](runs/2023-10-10/access/report/lines.svg)](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/access/report/index.html) 50 | 51 | *(`smartstring` is skipped due to how slow it is)* 52 | 53 | See [more details](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/access/report/index.html) 54 | 55 | `self_eq` summary: 56 | [![`self_eq`](runs/2023-10-10/self_eq/report/lines.svg)](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/self_eq/report/index.html) 57 | 58 | See [more details](https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/self_eq/report/index.html) 59 | 60 | # Special Thanks 61 | 62 | - djc for inspiration with [template-benchmarks-rs](https://github.com/djc/template-benchmarks-rs) 63 | -------------------------------------------------------------------------------- /benches/access.rs: -------------------------------------------------------------------------------- 1 | #![allow( 2 | clippy::clone_on_copy, 3 | clippy::useless_conversion, 4 | clippy::clone_double_ref 5 | )] 6 | 7 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; 8 | 9 | mod fixture; 10 | 11 | type StringCow<'s> = std::borrow::Cow<'s, str>; 12 | 13 | fn bench_access(c: &mut Criterion) { 14 | let mut group = c.benchmark_group("access"); 15 | for fixture in fixture::SAMPLES { 16 | let len = fixture.len(); 17 | group.throughput(Throughput::Bytes(len as u64)); 18 | group.bench_with_input(BenchmarkId::new("String", len), &len, |b, _| { 19 | let uut = String::from(*fixture); 20 | let uut = criterion::black_box(uut); 21 | b.iter(|| uut.is_empty()) 22 | }); 23 | group.bench_with_input(BenchmarkId::new("Box", len), &len, |b, _| { 24 | let uut = Box::::from(*fixture); 25 | let uut = criterion::black_box(uut); 26 | b.iter(|| uut.is_empty()) 27 | }); 28 | group.bench_with_input(BenchmarkId::new("Arc", len), &len, |b, _| { 29 | let uut = std::sync::Arc::::from(*fixture); 30 | let uut = criterion::black_box(uut); 31 | b.iter(|| uut.is_empty()) 32 | }); 33 | group.bench_with_input(BenchmarkId::new("StringCow::Owned", len), &len, |b, _| { 34 | let uut = StringCow::Owned(String::from(*fixture)); 35 | let uut = criterion::black_box(uut); 36 | b.iter(|| uut.is_empty()) 37 | }); 38 | 39 | group.bench_with_input(BenchmarkId::new("ArcStr::from", len), &len, |b, _| { 40 | let uut = arcstr::ArcStr::from(*fixture); 41 | let uut = criterion::black_box(uut); 42 | b.iter(|| uut.is_empty()) 43 | }); 44 | group.bench_with_input(BenchmarkId::new("CompactString::new", len), &len, |b, _| { 45 | let uut = compact_str::CompactString::new(fixture); 46 | let uut = criterion::black_box(uut); 47 | b.iter(|| uut.is_empty()) 48 | }); 49 | group.bench_with_input(BenchmarkId::new("EcoString::from", len), &len, |b, _| { 50 | let uut = ecow::EcoString::from(*fixture); 51 | let uut = criterion::black_box(uut); 52 | b.iter(|| uut.is_empty()) 53 | }); 54 | group.bench_with_input( 55 | BenchmarkId::new("flexstr::SharedStr::from_ref", len), 56 | &len, 57 | |b, _| { 58 | let uut = flexstr::SharedStr::from_ref(*fixture); 59 | let uut = criterion::black_box(uut); 60 | b.iter(|| uut.is_empty()) 61 | }, 62 | ); 63 | group.bench_with_input(BenchmarkId::new("HipStr::from", len), &len, |b, _| { 64 | let uut = hipstr::HipStr::from(*fixture); 65 | let uut = criterion::black_box(uut); 66 | b.iter(|| uut.is_empty()) 67 | }); 68 | group.bench_with_input(BenchmarkId::new("ImString::from", len), &len, |b, _| { 69 | let uut = imstr::ImString::from(*fixture); 70 | let uut = criterion::black_box(uut); 71 | b.iter(|| uut.is_empty()) 72 | }); 73 | group.bench_with_input(BenchmarkId::new("KString::from_ref", len), &len, |b, _| { 74 | let uut = kstring::KString::from_ref(*fixture); 75 | let uut = criterion::black_box(uut); 76 | b.iter(|| uut.is_empty()) 77 | }); 78 | group.bench_with_input( 79 | BenchmarkId::new("KString::from_string", len), 80 | &len, 81 | |b, _| { 82 | let uut = kstring::KString::from_string(String::from(*fixture)); 83 | let uut = criterion::black_box(uut); 84 | b.iter(|| uut.is_empty()) 85 | }, 86 | ); 87 | /* Skipped: orders of magnitude slower 88 | group.bench_with_input( 89 | BenchmarkId::new("smartstring::String::new", len), 90 | &len, 91 | |b, _| { 92 | let uut = smartstring::alias::String::from(*fixture); 93 | let uut = criterion::black_box(uut); 94 | b.iter(|| uut.is_empty()) 95 | }, 96 | ); 97 | */ 98 | } 99 | group.finish(); 100 | } 101 | 102 | fn bench_access_static(c: &mut Criterion) { 103 | let mut group = c.benchmark_group("access_static"); 104 | for fixture in fixture::SAMPLES { 105 | let len = fixture.len(); 106 | group.throughput(Throughput::Bytes(len as u64)); 107 | group.bench_with_input(BenchmarkId::new("&'static str", len), &len, |b, _| { 108 | let uut = *fixture; 109 | let uut = criterion::black_box(uut); 110 | b.iter(|| uut.is_empty()) 111 | }); 112 | group.bench_with_input( 113 | BenchmarkId::new("StringCow::Borrowed", len), 114 | &len, 115 | |b, _| { 116 | let uut = StringCow::Borrowed(*fixture); 117 | let uut = criterion::black_box(uut); 118 | b.iter(|| uut.is_empty()) 119 | }, 120 | ); 121 | group.bench_with_input( 122 | BenchmarkId::new("flexstr::SharedStr::from_static", len), 123 | &len, 124 | |b, _| { 125 | let uut = flexstr::SharedStr::from_static(*fixture); 126 | let uut = criterion::black_box(uut); 127 | b.iter(|| uut.is_empty()) 128 | }, 129 | ); 130 | group.bench_with_input( 131 | BenchmarkId::new("hipstr::HipStr::borrowed", len), 132 | &len, 133 | |b, _| { 134 | let uut = hipstr::HipStr::borrowed(*fixture); 135 | let uut = criterion::black_box(uut); 136 | b.iter(|| uut.is_empty()) 137 | }, 138 | ); 139 | group.bench_with_input( 140 | BenchmarkId::new("KString::from_static", len), 141 | &len, 142 | |b, _| { 143 | let uut = kstring::KString::from_static(*fixture); 144 | let uut = criterion::black_box(uut); 145 | b.iter(|| uut.is_empty()) 146 | }, 147 | ); 148 | } 149 | group.finish(); 150 | } 151 | 152 | criterion_group!(benches, bench_access, bench_access_static); 153 | criterion_main!(benches); 154 | -------------------------------------------------------------------------------- /benches/clone.rs: -------------------------------------------------------------------------------- 1 | #![allow( 2 | clippy::clone_on_copy, 3 | clippy::useless_conversion, 4 | clippy::clone_double_ref 5 | )] 6 | 7 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; 8 | 9 | mod fixture; 10 | 11 | type StringCow<'s> = std::borrow::Cow<'s, str>; 12 | 13 | fn bench_clone(c: &mut Criterion) { 14 | let mut group = c.benchmark_group("clone"); 15 | for fixture in fixture::SAMPLES { 16 | let len = fixture.len(); 17 | group.throughput(Throughput::Bytes(len as u64)); 18 | group.bench_with_input(BenchmarkId::new("String", len), &len, |b, _| { 19 | let uut = String::from(*fixture); 20 | let uut = criterion::black_box(uut); 21 | b.iter(|| uut.clone()) 22 | }); 23 | group.bench_with_input(BenchmarkId::new("Box", len), &len, |b, _| { 24 | let uut = Box::::from(*fixture); 25 | let uut = criterion::black_box(uut); 26 | b.iter(|| uut.clone()) 27 | }); 28 | group.bench_with_input(BenchmarkId::new("Arc", len), &len, |b, _| { 29 | let uut = std::sync::Arc::::from(*fixture); 30 | let uut = criterion::black_box(uut); 31 | b.iter(|| uut.clone()) 32 | }); 33 | group.bench_with_input(BenchmarkId::new("StringCow::Owned", len), &len, |b, _| { 34 | let uut = StringCow::Owned(String::from(*fixture)); 35 | let uut = criterion::black_box(uut); 36 | b.iter(|| uut.clone()) 37 | }); 38 | 39 | group.bench_with_input(BenchmarkId::new("ArcStr::from", len), &len, |b, _| { 40 | let uut = arcstr::ArcStr::from(*fixture); 41 | let uut = criterion::black_box(uut); 42 | b.iter(|| uut.clone()) 43 | }); 44 | group.bench_with_input(BenchmarkId::new("CompactString::new", len), &len, |b, _| { 45 | let uut = compact_str::CompactString::new(fixture); 46 | let uut = criterion::black_box(uut); 47 | b.iter(|| uut.clone()) 48 | }); 49 | group.bench_with_input(BenchmarkId::new("EcoString::from", len), &len, |b, _| { 50 | let uut = ecow::EcoString::from(*fixture); 51 | let uut = criterion::black_box(uut); 52 | b.iter(|| uut.clone()) 53 | }); 54 | group.bench_with_input( 55 | BenchmarkId::new("flexstr::SharedStr::from_ref", len), 56 | &len, 57 | |b, _| { 58 | let uut = flexstr::SharedStr::from_ref(*fixture); 59 | let uut = criterion::black_box(uut); 60 | b.iter(|| uut.clone()) 61 | }, 62 | ); 63 | group.bench_with_input(BenchmarkId::new("HipStr::from", len), &len, |b, _| { 64 | let uut = hipstr::HipStr::from(*fixture); 65 | let uut = criterion::black_box(uut); 66 | b.iter(|| uut.clone()) 67 | }); 68 | group.bench_with_input(BenchmarkId::new("ImString::from", len), &len, |b, _| { 69 | let uut = imstr::ImString::from(*fixture); 70 | let uut = criterion::black_box(uut); 71 | b.iter(|| uut.clone()) 72 | }); 73 | group.bench_with_input(BenchmarkId::new("KString::from_ref", len), &len, |b, _| { 74 | let uut = kstring::KString::from_ref(*fixture); 75 | let uut = criterion::black_box(uut); 76 | b.iter(|| uut.clone()) 77 | }); 78 | group.bench_with_input( 79 | BenchmarkId::new("KString::from_string", len), 80 | &len, 81 | |b, _| { 82 | let uut = kstring::KString::from_string(String::from(*fixture)); 83 | let uut = criterion::black_box(uut); 84 | b.iter(|| uut.clone()) 85 | }, 86 | ); 87 | group.bench_with_input( 88 | BenchmarkId::new("smartstring::String::new", len), 89 | &len, 90 | |b, _| { 91 | let uut = smartstring::alias::String::from(*fixture); 92 | let uut = criterion::black_box(uut); 93 | b.iter(|| uut.clone()) 94 | }, 95 | ); 96 | } 97 | group.finish(); 98 | } 99 | 100 | fn bench_clone_static(c: &mut Criterion) { 101 | let mut group = c.benchmark_group("clone_static"); 102 | for fixture in fixture::SAMPLES { 103 | let len = fixture.len(); 104 | group.throughput(Throughput::Bytes(len as u64)); 105 | group.bench_with_input(BenchmarkId::new("&'static str", len), &len, |b, _| { 106 | let uut = *fixture; 107 | let uut = criterion::black_box(uut); 108 | b.iter(|| uut.clone()) 109 | }); 110 | group.bench_with_input( 111 | BenchmarkId::new("StringCow::Borrowed", len), 112 | &len, 113 | |b, _| { 114 | let uut = StringCow::Borrowed(*fixture); 115 | let uut = criterion::black_box(uut); 116 | b.iter(|| uut.clone()) 117 | }, 118 | ); 119 | group.bench_with_input( 120 | BenchmarkId::new("flexstr::SharedStr::from_static", len), 121 | &len, 122 | |b, _| { 123 | let uut = flexstr::SharedStr::from_static(*fixture); 124 | let uut = criterion::black_box(uut); 125 | b.iter(|| uut.clone()) 126 | }, 127 | ); 128 | group.bench_with_input( 129 | BenchmarkId::new("hipstr::HipStr::borrowed", len), 130 | &len, 131 | |b, _| { 132 | let uut = hipstr::HipStr::borrowed(*fixture); 133 | let uut = criterion::black_box(uut); 134 | b.iter(|| uut.clone()) 135 | }, 136 | ); 137 | group.bench_with_input( 138 | BenchmarkId::new("KString::from_static", len), 139 | &len, 140 | |b, _| { 141 | let uut = kstring::KString::from_static(*fixture); 142 | let uut = criterion::black_box(uut); 143 | b.iter(|| uut.clone()) 144 | }, 145 | ); 146 | } 147 | group.finish(); 148 | } 149 | 150 | criterion_group!(benches, bench_clone, bench_clone_static); 151 | criterion_main!(benches); 152 | -------------------------------------------------------------------------------- /benches/fixture.rs: -------------------------------------------------------------------------------- 1 | pub const SAMPLES: &[&str] = &[ 2 | // Empty handling 3 | "", 4 | // Barely used 5 | "1", 6 | // kstring's max small-string size 7 | "123456789012345", 8 | // Boundary conditions for most small-string optimizations 9 | "1234567890123456789012", 10 | "12345678901234567890123", 11 | "123456789012345678901234", 12 | "1234567890123456789012345", 13 | // Small heap 14 | "1234567890123456789012345678901234567890123456789012345678901234", 15 | // Large heap 16 | "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 17 | ]; 18 | -------------------------------------------------------------------------------- /benches/new.rs: -------------------------------------------------------------------------------- 1 | #![allow( 2 | clippy::clone_on_copy, 3 | clippy::useless_conversion, 4 | clippy::clone_double_ref 5 | )] 6 | 7 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; 8 | 9 | mod fixture; 10 | 11 | type StringCow<'s> = std::borrow::Cow<'s, str>; 12 | 13 | fn bench_new(c: &mut Criterion) { 14 | let mut group = c.benchmark_group("new"); 15 | for fixture in fixture::SAMPLES { 16 | let len = fixture.len(); 17 | group.throughput(Throughput::Bytes(len as u64)); 18 | group.bench_with_input(BenchmarkId::new("String", len), &len, |b, _| { 19 | let fixture = criterion::black_box(*fixture); 20 | b.iter(|| String::from(fixture)) 21 | }); 22 | group.bench_with_input(BenchmarkId::new("Box", len), &len, |b, _| { 23 | let fixture = criterion::black_box(*fixture); 24 | b.iter(|| Box::::from(fixture)) 25 | }); 26 | group.bench_with_input(BenchmarkId::new("Arc", len), &len, |b, _| { 27 | let fixture = criterion::black_box(*fixture); 28 | b.iter(|| std::sync::Arc::::from(fixture)) 29 | }); 30 | group.bench_with_input(BenchmarkId::new("StringCow::Owned", len), &len, |b, _| { 31 | let fixture = criterion::black_box(*fixture); 32 | b.iter(|| StringCow::Owned(String::from(fixture))) 33 | }); 34 | 35 | group.bench_with_input(BenchmarkId::new("ArcStr::from", len), &len, |b, _| { 36 | let fixture = criterion::black_box(*fixture); 37 | b.iter(|| arcstr::ArcStr::from(fixture)) 38 | }); 39 | group.bench_with_input(BenchmarkId::new("CompactString::new", len), &len, |b, _| { 40 | let fixture = criterion::black_box(*fixture); 41 | b.iter(|| compact_str::CompactString::new(fixture)) 42 | }); 43 | group.bench_with_input(BenchmarkId::new("EcoString::from", len), &len, |b, _| { 44 | let fixture = criterion::black_box(*fixture); 45 | b.iter(|| ecow::EcoString::from(fixture)) 46 | }); 47 | group.bench_with_input( 48 | BenchmarkId::new("flexstr::SharedStr::from_ref", len), 49 | &len, 50 | |b, _| { 51 | let fixture = criterion::black_box(*fixture); 52 | b.iter(|| flexstr::SharedStr::from_ref(fixture)) 53 | }, 54 | ); 55 | group.bench_with_input(BenchmarkId::new("HipStr::from", len), &len, |b, _| { 56 | let fixture = criterion::black_box(*fixture); 57 | b.iter(|| hipstr::HipStr::from(fixture)) 58 | }); 59 | group.bench_with_input(BenchmarkId::new("ImString::from", len), &len, |b, _| { 60 | let fixture = criterion::black_box(*fixture); 61 | b.iter(|| imstr::ImString::from(fixture)) 62 | }); 63 | group.bench_with_input(BenchmarkId::new("KString::from_ref", len), &len, |b, _| { 64 | let fixture = criterion::black_box(*fixture); 65 | b.iter(|| kstring::KString::from_ref(fixture)) 66 | }); 67 | group.bench_with_input( 68 | BenchmarkId::new("KString::from_string", len), 69 | &len, 70 | |b, _| { 71 | let fixture = criterion::black_box(*fixture); 72 | b.iter(|| kstring::KString::from_string(String::from(fixture))) 73 | }, 74 | ); 75 | group.bench_with_input( 76 | BenchmarkId::new("smartstring::String::new", len), 77 | &len, 78 | |b, _| { 79 | let fixture = criterion::black_box(*fixture); 80 | b.iter(|| smartstring::alias::String::from(fixture)) 81 | }, 82 | ); 83 | } 84 | group.finish(); 85 | } 86 | 87 | fn bench_new_static(c: &mut Criterion) { 88 | let mut group = c.benchmark_group("new_static"); 89 | for fixture in fixture::SAMPLES { 90 | let len = fixture.len(); 91 | group.throughput(Throughput::Bytes(len as u64)); 92 | group.bench_with_input( 93 | BenchmarkId::new("StringCow::Borrowed", len), 94 | &len, 95 | |b, _| { 96 | let fixture = criterion::black_box(*fixture); 97 | b.iter(|| StringCow::Borrowed(fixture)) 98 | }, 99 | ); 100 | group.bench_with_input( 101 | BenchmarkId::new("flexstr::SharedStr::from_static", len), 102 | &len, 103 | |b, _| { 104 | let fixture = criterion::black_box(*fixture); 105 | b.iter(|| flexstr::SharedStr::from_static(fixture)) 106 | }, 107 | ); 108 | group.bench_with_input( 109 | BenchmarkId::new("hipstr::HipStr::borrowed", len), 110 | &len, 111 | |b, _| { 112 | let fixture = criterion::black_box(*fixture); 113 | b.iter(|| hipstr::HipStr::borrowed(fixture)) 114 | }, 115 | ); 116 | group.bench_with_input( 117 | BenchmarkId::new("KString::from_static", len), 118 | &len, 119 | |b, _| { 120 | let fixture = criterion::black_box(*fixture); 121 | b.iter(|| kstring::KString::from_static(fixture)) 122 | }, 123 | ); 124 | } 125 | group.finish(); 126 | } 127 | 128 | criterion_group!(benches, bench_new, bench_new_static); 129 | criterion_main!(benches); 130 | -------------------------------------------------------------------------------- /benches/self_eq.rs: -------------------------------------------------------------------------------- 1 | #![allow( 2 | clippy::clone_on_copy, 3 | clippy::useless_conversion, 4 | clippy::clone_double_ref 5 | )] 6 | 7 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; 8 | 9 | mod fixture; 10 | 11 | type StringCow<'s> = std::borrow::Cow<'s, str>; 12 | 13 | fn bench_self_eq(c: &mut Criterion) { 14 | let mut group = c.benchmark_group("self_eq"); 15 | for fixture in fixture::SAMPLES { 16 | let len = fixture.len(); 17 | group.throughput(Throughput::Bytes(len as u64)); 18 | group.bench_with_input(BenchmarkId::new("String", len), &len, |b, _| { 19 | let uut = String::from(*fixture); 20 | let uut = criterion::black_box(uut); 21 | let copy = uut.clone(); 22 | let copy = criterion::black_box(copy); 23 | b.iter(|| uut == copy) 24 | }); 25 | group.bench_with_input(BenchmarkId::new("Box", len), &len, |b, _| { 26 | let uut = Box::::from(*fixture); 27 | let uut = criterion::black_box(uut); 28 | let copy = uut.clone(); 29 | let copy = criterion::black_box(copy); 30 | b.iter(|| uut == copy) 31 | }); 32 | group.bench_with_input(BenchmarkId::new("Arc", len), &len, |b, _| { 33 | let uut = std::sync::Arc::::from(*fixture); 34 | let uut = criterion::black_box(uut); 35 | let copy = uut.clone(); 36 | let copy = criterion::black_box(copy); 37 | b.iter(|| uut == copy) 38 | }); 39 | group.bench_with_input(BenchmarkId::new("StringCow::Owned", len), &len, |b, _| { 40 | let uut = StringCow::Owned(String::from(*fixture)); 41 | let uut = criterion::black_box(uut); 42 | let copy = uut.clone(); 43 | let copy = criterion::black_box(copy); 44 | b.iter(|| uut == copy) 45 | }); 46 | 47 | group.bench_with_input(BenchmarkId::new("ArcStr::from", len), &len, |b, _| { 48 | let uut = arcstr::ArcStr::from(*fixture); 49 | let uut = criterion::black_box(uut); 50 | let copy = uut.clone(); 51 | let copy = criterion::black_box(copy); 52 | b.iter(|| uut == copy) 53 | }); 54 | group.bench_with_input(BenchmarkId::new("CompactString::new", len), &len, |b, _| { 55 | let uut = compact_str::CompactString::new(fixture); 56 | let uut = criterion::black_box(uut); 57 | let copy = uut.clone(); 58 | let copy = criterion::black_box(copy); 59 | b.iter(|| uut == copy) 60 | }); 61 | group.bench_with_input(BenchmarkId::new("EcoString::from", len), &len, |b, _| { 62 | let uut = ecow::EcoString::from(*fixture); 63 | let uut = criterion::black_box(uut); 64 | let copy = uut.clone(); 65 | let copy = criterion::black_box(copy); 66 | b.iter(|| uut == copy) 67 | }); 68 | group.bench_with_input( 69 | BenchmarkId::new("flexstr::SharedStr::from_ref", len), 70 | &len, 71 | |b, _| { 72 | let uut = flexstr::SharedStr::from_ref(*fixture); 73 | let uut = criterion::black_box(uut); 74 | let copy = uut.clone(); 75 | let copy = criterion::black_box(copy); 76 | b.iter(|| uut == copy) 77 | }, 78 | ); 79 | group.bench_with_input(BenchmarkId::new("HipStr::from", len), &len, |b, _| { 80 | let uut = hipstr::HipStr::from(*fixture); 81 | let uut = criterion::black_box(uut); 82 | let copy = uut.clone(); 83 | let copy = criterion::black_box(copy); 84 | b.iter(|| uut == copy) 85 | }); 86 | group.bench_with_input(BenchmarkId::new("ImString::from", len), &len, |b, _| { 87 | let uut = imstr::ImString::from(*fixture); 88 | let uut = criterion::black_box(uut); 89 | let copy = uut.clone(); 90 | let copy = criterion::black_box(copy); 91 | b.iter(|| uut == copy) 92 | }); 93 | group.bench_with_input(BenchmarkId::new("KString::from_ref", len), &len, |b, _| { 94 | let uut = kstring::KString::from_ref(*fixture); 95 | let uut = criterion::black_box(uut); 96 | let copy = uut.clone(); 97 | let copy = criterion::black_box(copy); 98 | b.iter(|| uut == copy) 99 | }); 100 | group.bench_with_input( 101 | BenchmarkId::new("KString::from_string", len), 102 | &len, 103 | |b, _| { 104 | let uut = kstring::KString::from_string(String::from(*fixture)); 105 | let uut = criterion::black_box(uut); 106 | let copy = uut.clone(); 107 | let copy = criterion::black_box(copy); 108 | b.iter(|| uut == copy) 109 | }, 110 | ); 111 | /* Skipped: orders of magnitude slower 112 | group.bench_with_input( 113 | BenchmarkId::new("smartstring::String::new", len), 114 | &len, 115 | |b, _| { 116 | let uut = smartstring::alias::String::from(*fixture); 117 | let uut = criterion::black_box(uut); 118 | let copy = uut.clone(); 119 | let copy = criterion::black_box(copy); 120 | b.iter(|| uut == copy) 121 | }, 122 | ); 123 | */ 124 | } 125 | group.finish(); 126 | } 127 | 128 | fn bench_self_eq_static(c: &mut Criterion) { 129 | let mut group = c.benchmark_group("self_eq_static"); 130 | for fixture in fixture::SAMPLES { 131 | let len = fixture.len(); 132 | group.throughput(Throughput::Bytes(len as u64)); 133 | group.bench_with_input(BenchmarkId::new("&'static str", len), &len, |b, _| { 134 | let uut = *fixture; 135 | let uut = criterion::black_box(uut); 136 | let copy = uut.clone(); 137 | let copy = criterion::black_box(copy); 138 | b.iter(|| uut == copy) 139 | }); 140 | group.bench_with_input( 141 | BenchmarkId::new("StringCow::Borrowed", len), 142 | &len, 143 | |b, _| { 144 | let uut = StringCow::Borrowed(*fixture); 145 | let uut = criterion::black_box(uut); 146 | let copy = uut.clone(); 147 | let copy = criterion::black_box(copy); 148 | b.iter(|| uut == copy) 149 | }, 150 | ); 151 | group.bench_with_input( 152 | BenchmarkId::new("flexstr::SharedStr::from_static", len), 153 | &len, 154 | |b, _| { 155 | let uut = flexstr::SharedStr::from_static(*fixture); 156 | let uut = criterion::black_box(uut); 157 | let copy = uut.clone(); 158 | let copy = criterion::black_box(copy); 159 | b.iter(|| uut == copy) 160 | }, 161 | ); 162 | group.bench_with_input( 163 | BenchmarkId::new("hipstr::HipStr::borrowed", len), 164 | &len, 165 | |b, _| { 166 | let uut = hipstr::HipStr::borrowed(*fixture); 167 | let uut = criterion::black_box(uut); 168 | let copy = uut.clone(); 169 | let copy = criterion::black_box(copy); 170 | b.iter(|| uut == copy) 171 | }, 172 | ); 173 | group.bench_with_input( 174 | BenchmarkId::new("KString::from_static", len), 175 | &len, 176 | |b, _| { 177 | let uut = kstring::KString::from_static(*fixture); 178 | let uut = criterion::black_box(uut); 179 | let copy = uut.clone(); 180 | let copy = criterion::black_box(copy); 181 | b.iter(|| uut == copy) 182 | }, 183 | ); 184 | } 185 | group.finish(); 186 | } 187 | 188 | criterion_group!(benches, bench_self_eq, bench_self_eq_static); 189 | criterion_main!(benches); 190 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | # Note that all fields that take a lint level have these possible values: 2 | # * deny - An error will be produced and the check will fail 3 | # * warn - A warning will be produced, but the check will not fail 4 | # * allow - No warning or error will be produced, though in some cases a note 5 | # will be 6 | 7 | # This section is considered when running `cargo deny check advisories` 8 | # More documentation for the advisories section can be found here: 9 | # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html 10 | [advisories] 11 | # The lint level for security vulnerabilities 12 | vulnerability = "deny" 13 | # The lint level for unmaintained crates 14 | unmaintained = "warn" 15 | # The lint level for crates that have been yanked from their source registry 16 | yanked = "warn" 17 | # The lint level for crates with security notices. Note that as of 18 | # 2019-12-17 there are no security notice advisories in 19 | # https://github.com/rustsec/advisory-db 20 | notice = "warn" 21 | # A list of advisory IDs to ignore. Note that ignored advisories will still 22 | # output a note when they are encountered. 23 | # 24 | # e.g. "RUSTSEC-0000-0000", 25 | ignore = [ 26 | ] 27 | 28 | # This section is considered when running `cargo deny check licenses` 29 | # More documentation for the licenses section can be found here: 30 | # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html 31 | [licenses] 32 | unlicensed = "deny" 33 | # List of explicitly allowed licenses 34 | # See https://spdx.org/licenses/ for list of possible licenses 35 | # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. 36 | allow = [ 37 | "MIT", 38 | "MIT-0", 39 | "Apache-2.0", 40 | "BSD-3-Clause", 41 | "MPL-2.0", 42 | "Unicode-DFS-2016", 43 | "CC0-1.0", 44 | ] 45 | # List of explicitly disallowed licenses 46 | # See https://spdx.org/licenses/ for list of possible licenses 47 | # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. 48 | deny = [ 49 | ] 50 | # Lint level for licenses considered copyleft 51 | copyleft = "deny" 52 | # Blanket approval or denial for OSI-approved or FSF Free/Libre licenses 53 | # * both - The license will be approved if it is both OSI-approved *AND* FSF 54 | # * either - The license will be approved if it is either OSI-approved *OR* FSF 55 | # * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF 56 | # * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved 57 | # * neither - This predicate is ignored and the default lint level is used 58 | allow-osi-fsf-free = "neither" 59 | # Lint level used when no other predicates are matched 60 | # 1. License isn't in the allow or deny lists 61 | # 2. License isn't copyleft 62 | # 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" 63 | default = "deny" 64 | # The confidence threshold for detecting a license from license text. 65 | # The higher the value, the more closely the license text must be to the 66 | # canonical license text of a valid SPDX license file. 67 | # [possible values: any between 0.0 and 1.0]. 68 | confidence-threshold = 0.8 69 | # Allow 1 or more licenses on a per-crate basis, so that particular licenses 70 | # aren't accepted for every possible crate as with the normal allow list 71 | exceptions = [ 72 | # Each entry is the crate and version constraint, and its specific allow 73 | # list 74 | #{ allow = ["Zlib"], name = "adler32", version = "*" }, 75 | ] 76 | 77 | [licenses.private] 78 | # If true, ignores workspace crates that aren't published, or are only 79 | # published to private registries. 80 | # To see how to mark a crate as unpublished (to the official registry), 81 | # visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. 82 | ignore = true 83 | 84 | # This section is considered when running `cargo deny check bans`. 85 | # More documentation about the 'bans' section can be found here: 86 | # https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html 87 | [bans] 88 | # Lint level for when multiple versions of the same crate are detected 89 | multiple-versions = "warn" 90 | # Lint level for when a crate version requirement is `*` 91 | wildcards = "deny" 92 | # The graph highlighting used when creating dotgraphs for crates 93 | # with multiple versions 94 | # * lowest-version - The path to the lowest versioned duplicate is highlighted 95 | # * simplest-path - The path to the version with the fewest edges is highlighted 96 | # * all - Both lowest-version and simplest-path are used 97 | highlight = "all" 98 | # The default lint level for `default` features for crates that are members of 99 | # the workspace that is being checked. This can be overridden by allowing/denying 100 | # `default` on a crate-by-crate basis if desired. 101 | workspace-default-features = "allow" 102 | # The default lint level for `default` features for external crates that are not 103 | # members of the workspace. This can be overridden by allowing/denying `default` 104 | # on a crate-by-crate basis if desired. 105 | external-default-features = "allow" 106 | # List of crates that are allowed. Use with care! 107 | allow = [ 108 | #{ name = "ansi_term", version = "=0.11.0" }, 109 | ] 110 | # List of crates to deny 111 | deny = [ 112 | # Each entry the name of a crate and a version range. If version is 113 | # not specified, all versions will be matched. 114 | #{ name = "ansi_term", version = "=0.11.0" }, 115 | # 116 | # Wrapper crates can optionally be specified to allow the crate when it 117 | # is a direct dependency of the otherwise banned crate 118 | #{ name = "ansi_term", version = "=0.11.0", wrappers = [] }, 119 | ] 120 | 121 | # This section is considered when running `cargo deny check sources`. 122 | # More documentation about the 'sources' section can be found here: 123 | # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html 124 | [sources] 125 | # Lint level for what to happen when a crate from a crate registry that is not 126 | # in the allow list is encountered 127 | unknown-registry = "deny" 128 | # Lint level for what to happen when a crate from a git repository that is not 129 | # in the allow list is encountered 130 | unknown-git = "deny" 131 | # List of URLs for allowed crate registries. Defaults to the crates.io index 132 | # if not specified. If it is specified but empty, no registries are allowed. 133 | allow-registry = ["https://github.com/rust-lang/crates.io-index"] 134 | # List of URLs for allowed Git repositories 135 | allow-git = [] 136 | 137 | [sources.allow-org] 138 | # 1 or more github.com organizations to allow git sources for 139 | github = [] 140 | -------------------------------------------------------------------------------- /runs/2022-03-25/access/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | access Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

access

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-25/clone/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | clone Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

clone

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-25/new/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | new Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

new

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-25/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Index - Criterion.rs 7 | 60 | 61 | 62 | 63 |
64 |

Criterion.rs Benchmark Index

65 | See individual benchmark pages below for more details. 66 | 71 |
72 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /runs/2022-03-30/access/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | access Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

access

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/access_static/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | access_static Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

access_static

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/clone/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | clone Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

clone

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/clone_static/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | clone_static Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

clone_static

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/new/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | new Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

new

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/new_static/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | new_static Summary - Criterion.rs 7 | 50 | 51 | 52 | 53 |
54 |

new_static

55 |

Violin Plot

56 | 57 | Violin Plot 58 | 59 |

This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded 60 | region indicates the probability that a measurement of the given function/parameter would take a particular 61 | length of time.

62 |

Line Chart

63 | Line Chart 64 |

This chart shows the mean measured time for each function as the input (or the size of the input) increases.

65 |
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /runs/2022-03-30/new_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0.5 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 1.5 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 2 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 2.5 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 3 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 3.5 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 4 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 4.5 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 5 171 | 172 | 173 | 174 | 175 | 0 176 | 177 | 178 | 179 | 180 | 100 181 | 182 | 183 | 184 | 185 | 200 186 | 187 | 188 | 189 | 190 | 300 191 | 192 | 193 | 194 | 195 | 400 196 | 197 | 198 | 199 | 200 | 500 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Average time (ns) 210 | 211 | 212 | 213 | 214 | Input Size (Bytes) 215 | 216 | 217 | 218 | 219 | new_static: Comparison 220 | 221 | 222 | 223 | 224 | KString::from_static 225 | 226 | 227 | 228 | 229 | KString::from_static 230 | 231 | 232 | 233 | 235 | 236 | gnuplot_plot_2 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | StringCow::Borrowed 252 | 253 | 254 | 255 | 256 | StringCow::Borrowed 257 | 258 | 259 | 260 | 262 | 263 | gnuplot_plot_4 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | flexstr::SharedStr::from_static 279 | 280 | 281 | 282 | 283 | flexstr::SharedStr::from_static 284 | 285 | 286 | 287 | 289 | 290 | gnuplot_plot_6 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /runs/2022-03-30/report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Index - Criterion.rs 7 | 60 | 61 | 62 | 63 |
64 |

Criterion.rs Benchmark Index

65 | See individual benchmark pages below for more details. 66 | 74 |
75 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /runs/2023-08-16/access_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 251 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 251.5 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 252 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 252.5 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 253 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 253.5 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 254 132 | 133 | 134 | 135 | 136 | 0 137 | 138 | 139 | 140 | 141 | 100 142 | 143 | 144 | 145 | 146 | 200 147 | 148 | 149 | 150 | 151 | 300 152 | 153 | 154 | 155 | 156 | 400 157 | 158 | 159 | 160 | 161 | 500 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | Average time (ps) 171 | 172 | 173 | 174 | 175 | Input Size (Bytes) 176 | 177 | 178 | 179 | 180 | access_static: Comparison 181 | 182 | 183 | 184 | 185 | 'static str 186 | 187 | 188 | 189 | 190 | 'static str 191 | 192 | 193 | 194 | 196 | 197 | gnuplot_plot_2 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | KString::from_static 213 | 214 | 215 | 216 | 217 | KString::from_static 218 | 219 | 220 | 221 | 223 | 224 | gnuplot_plot_4 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | StringCow::Borrowed 240 | 241 | 242 | 243 | 244 | StringCow::Borrowed 245 | 246 | 247 | 248 | 250 | 251 | gnuplot_plot_6 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | flexstr::SharedStr::from_static 267 | 268 | 269 | 270 | 271 | flexstr::SharedStr::from_static 272 | 273 | 274 | 275 | 277 | 278 | gnuplot_plot_8 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /runs/2023-08-16/new_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0.5 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 1.5 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 2 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 2.5 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 3 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 3.5 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 4 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 4.5 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 5 171 | 172 | 173 | 174 | 175 | 0 176 | 177 | 178 | 179 | 180 | 100 181 | 182 | 183 | 184 | 185 | 200 186 | 187 | 188 | 189 | 190 | 300 191 | 192 | 193 | 194 | 195 | 400 196 | 197 | 198 | 199 | 200 | 500 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Average time (ns) 210 | 211 | 212 | 213 | 214 | Input Size (Bytes) 215 | 216 | 217 | 218 | 219 | new_static: Comparison 220 | 221 | 222 | 223 | 224 | KString::from_static 225 | 226 | 227 | 228 | 229 | KString::from_static 230 | 231 | 232 | 233 | 235 | 236 | gnuplot_plot_2 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | StringCow::Borrowed 252 | 253 | 254 | 255 | 256 | StringCow::Borrowed 257 | 258 | 259 | 260 | 262 | 263 | gnuplot_plot_4 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | flexstr::SharedStr::from_static 279 | 280 | 281 | 282 | 283 | flexstr::SharedStr::from_static 284 | 285 | 286 | 287 | 289 | 290 | gnuplot_plot_6 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /runs/2023-08-17/new_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0.5 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 1.5 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 2 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 2.5 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 3 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 3.5 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 4 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 4.5 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 5 171 | 172 | 173 | 174 | 175 | 0 176 | 177 | 178 | 179 | 180 | 100 181 | 182 | 183 | 184 | 185 | 200 186 | 187 | 188 | 189 | 190 | 300 191 | 192 | 193 | 194 | 195 | 400 196 | 197 | 198 | 199 | 200 | 500 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Average time (ns) 210 | 211 | 212 | 213 | 214 | Input Size (Bytes) 215 | 216 | 217 | 218 | 219 | new_static: Comparison 220 | 221 | 222 | 223 | 224 | KString::from_static 225 | 226 | 227 | 228 | 229 | KString::from_static 230 | 231 | 232 | 233 | 235 | 236 | gnuplot_plot_2 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | StringCow::Borrowed 252 | 253 | 254 | 255 | 256 | StringCow::Borrowed 257 | 258 | 259 | 260 | 262 | 263 | gnuplot_plot_4 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | flexstr::SharedStr::from_static 279 | 280 | 281 | 282 | 283 | flexstr::SharedStr::from_static 284 | 285 | 286 | 287 | 289 | 290 | gnuplot_plot_6 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /runs/2023-10-10/access_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 249.5 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 250 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 250.5 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 251 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 251.5 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 252 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 252.5 132 | 133 | 134 | 135 | 136 | 0 137 | 138 | 139 | 140 | 141 | 100 142 | 143 | 144 | 145 | 146 | 200 147 | 148 | 149 | 150 | 151 | 300 152 | 153 | 154 | 155 | 156 | 400 157 | 158 | 159 | 160 | 161 | 500 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | Average time (ps) 171 | 172 | 173 | 174 | 175 | Input Size (Bytes) 176 | 177 | 178 | 179 | 180 | access_static: Comparison 181 | 182 | 183 | 184 | 185 | 'static str 186 | 187 | 188 | 189 | 190 | 'static str 191 | 192 | 193 | 194 | 196 | 197 | gnuplot_plot_2 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | KString::from_static 213 | 214 | 215 | 216 | 217 | KString::from_static 218 | 219 | 220 | 221 | 223 | 224 | gnuplot_plot_4 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | StringCow::Borrowed 240 | 241 | 242 | 243 | 244 | StringCow::Borrowed 245 | 246 | 247 | 248 | 250 | 251 | gnuplot_plot_6 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | flexstr::SharedStr::from_static 267 | 268 | 269 | 270 | 271 | flexstr::SharedStr::from_static 272 | 273 | 274 | 275 | 277 | 278 | gnuplot_plot_8 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /runs/2023-10-10/new_static/report/lines.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Gnuplot 9 | Produced by GNUPLOT 5.2 patchlevel 8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0.5 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 1.5 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 2 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 2.5 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 3 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 3.5 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 4 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 4.5 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 5 171 | 172 | 173 | 174 | 175 | 0 176 | 177 | 178 | 179 | 180 | 100 181 | 182 | 183 | 184 | 185 | 200 186 | 187 | 188 | 189 | 190 | 300 191 | 192 | 193 | 194 | 195 | 400 196 | 197 | 198 | 199 | 200 | 500 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Average time (ns) 210 | 211 | 212 | 213 | 214 | Input Size (Bytes) 215 | 216 | 217 | 218 | 219 | new_static: Comparison 220 | 221 | 222 | 223 | 224 | KString::from_static 225 | 226 | 227 | 228 | 229 | KString::from_static 230 | 231 | 232 | 233 | 235 | 236 | gnuplot_plot_2 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | StringCow::Borrowed 252 | 253 | 254 | 255 | 256 | StringCow::Borrowed 257 | 258 | 259 | 260 | 262 | 263 | gnuplot_plot_4 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | flexstr::SharedStr::from_static 279 | 280 | 281 | 282 | 283 | flexstr::SharedStr::from_static 284 | 285 | 286 | 287 | 289 | 290 | gnuplot_plot_6 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("String {} bytes", std::mem::size_of::()); 3 | println!("&'static str {} bytes", std::mem::size_of::<&'static str>()); 4 | println!( 5 | "Cow {} bytes", 6 | std::mem::size_of::>() 7 | ); 8 | 9 | println!("ArcStr {} bytes", std::mem::size_of::()); 10 | println!( 11 | "CompactString {} bytes", 12 | std::mem::size_of::() 13 | ); 14 | println!("ecow {} bytes", std::mem::size_of::()); 15 | println!( 16 | "FlexStr {} bytes", 17 | std::mem::size_of::() 18 | ); 19 | println!("HipStr {} bytes", std::mem::size_of::()); 20 | println!("ImString {} bytes", std::mem::size_of::()); 21 | println!("KString {} bytes", std::mem::size_of::()); 22 | println!( 23 | "SmartString {} bytes", 24 | std::mem::size_of::() 25 | ); 26 | } 27 | --------------------------------------------------------------------------------