Code Monkey home page Code Monkey logo

string-rosetta-rs's Introduction

Rust String Benchmarks

This repo tries to assess Rust string types.

We currently compare:

Name Size Heap Inline &'static str Mutable Unsafe Notes
String 24 bytes Y - N Y - Universal
Cow<'static, str> 24 bytes Y - Y N -
arcstr 8 bytes ? ? ? ? ? ?
compact_str 24 bytes Y 24 bytes N Y Y (miri, proptest, fuzz) Space optimized for Option<_>
ecow 16 bytes Y 15 bytes N Y Y (miri) O(1) clone unless mutated, Space optimized for Option<_>
flexstr 24 bytes Y 22 bytes Y N Y (miri) O(1) clone
hipstr 24 bytes ? ? ? ? ? ?
imstr 24 bytes ? ? ? ? ? ?
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
smartstring 24 bytes Y 23 bytes N Y Y (miri, proptest, fuzz)

Suggestions:

  • Generally, String
  • If you deal mostly with string literals but want some flexibility (like clap), generally you'll want Cow<'static, str>
  • If a profiler says your strings are a problem:
    • Try different crates and settings for that crate out with a profiler
    • O(1) clones are important when doing a lot of clones. For one-off allocations, they are slower.
    • For short-lived programs, look into string interning

Note: smol_str was removed in favor of ecow

Terms:

  • Heap: will store strings in heap-allocated memory
  • Inline: will store small-enough strings on the stack

Results

new summary: new

See more details

clone summary: clone

See more details

access summary: access

See more details

Special Thanks

string-rosetta-rs's People

Contributors

epage avatar dependabot[bot] avatar renovate[bot] avatar parkmycar avatar laurmaedje avatar

Watchers

Sammy filly  avatar

string-rosetta-rs's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update compatible (arcstr, compact_str)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
Cargo.toml
  • arcstr 1.1.5
  • compact_str 0.7
  • ecow 0.1.1
  • flexstr 0.9.2
  • hipstr 0.3.1
  • imstr 0.2.0
  • kstring 2.0.0
  • smartstring 1.0.1
  • criterion 0.5.1
github-actions
.github/workflows/audit.yml
  • actions/checkout v3
  • actions-rs/audit-check v1
  • actions/checkout v3
  • EmbarkStudios/cargo-deny-action v1
.github/workflows/ci.yml
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • github/codeql-action v2

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.