All Projects → dhasenan → Faststring

dhasenan / Faststring

Licence: mit
Strings in a hurry.

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Faststring

Profimp
Python import profiler
Stars: ✭ 52 (-20%)
Mutual labels:  performance
Kirby3 Autoid
Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
Stars: ✭ 58 (-10.77%)
Mutual labels:  performance
Swisstable
Access Abseil Swiss Tables from C
Stars: ✭ 61 (-6.15%)
Mutual labels:  performance
Goldiloader
Just the right amount of Rails eager loading
Stars: ✭ 1,074 (+1552.31%)
Mutual labels:  performance
Copona
A free shopping cart system, based on OpenCart (http://www.opencart.com). An ideal alternative to Opencart, rich to develop - easy to use! Read Wiki for improvements over Opencart.
Stars: ✭ 56 (-13.85%)
Mutual labels:  performance
Cmov
Measuring cmov vs branch-mov performance
Stars: ✭ 58 (-10.77%)
Mutual labels:  performance
Observer cli
Visualize Erlang/Elixir Nodes On The Command Line
Stars: ✭ 1,058 (+1527.69%)
Mutual labels:  performance
Traceshark
This is a tool for Linux kernel ftrace and perf events visualization
Stars: ✭ 63 (-3.08%)
Mutual labels:  performance
Pc Optimization Hub
collection of various resources devoted to performance and input lag optimization
Stars: ✭ 55 (-15.38%)
Mutual labels:  performance
Packagephobia
⚖️ Find the cost of adding a new dependency to your project
Stars: ✭ 1,110 (+1607.69%)
Mutual labels:  performance
Pgtune
Pgtune - tuning PostgreSQL config by your hardware
Stars: ✭ 1,078 (+1558.46%)
Mutual labels:  performance
Staged Streams.scala
Stars: ✭ 55 (-15.38%)
Mutual labels:  performance
Mud
MUD is a layer over Overtone to make live composition more powerful and immediate.
Stars: ✭ 58 (-10.77%)
Mutual labels:  performance
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-16.92%)
Mutual labels:  performance
Vcprofiler
An accurate and simple tool uses KVO to measure the time cost of every view controller.
Stars: ✭ 61 (-6.15%)
Mutual labels:  performance
Aws Power Tuner Ui
AWS Lambda Power Tuner UI is an open source project creating a deployable easy to use website built on a layered technology stack allowing you to optimize your Lambda functions for cost and/or performance in a data-driven way via an easy to use UI.
Stars: ✭ 52 (-20%)
Mutual labels:  performance
Performance Column
🚅 性能专栏(Performance Column)
Stars: ✭ 1,097 (+1587.69%)
Mutual labels:  performance
Wprig
A progressive theme development rig for WordPress.
Stars: ✭ 1,125 (+1630.77%)
Mutual labels:  performance
Efsecondlevelcache
Entity Framework 6.x Second Level Caching Library.
Stars: ✭ 63 (-3.08%)
Mutual labels:  performance
Phpspy
Low-overhead sampling profiler for PHP 7+
Stars: ✭ 1,105 (+1600%)
Mutual labels:  performance

FastString: strings in a hurry

.NET's builtin strings are convenient. However, they are not designed with performance in mind.

FastString offers currently two methods for working with strings that can be significantly faster than .NET's:

StringView

Strings are immutable. Taking a substring does not need to allocate memory. However, System.String copies over data when you take a substring.

StringView addresses that. It's a view into a slice of a string, supporting some of the same operations. (In the long term, I aim to extend it to support the same interface as System.String.)

StringView is good for substrings that do not significantly outlive the string they came from. If you extract out a small subset of a large string with StringView and then throw out that large string, it's kept in memory until the StringView goes out of scope. Not so great for grabbing just a couple values from a giant configuration file, for instance.

StringView is a struct to reduce allocations further.

utf8

The world has largely settled on UTF8 as the standard string format. Why transcode to UTF16 and back constantly?

The utf8 struct aims for System.String parity, but using UTF8 as the encoding. Like StringView, it allocates as little as possible.

Its allied types are:

  • Utf8Enumerator: iterate through Unicode codepoints in a utf8 string.
  • ReverseUtf8Enumerator: iterate through Unicode codepoints in a utf8 string, backwards.
  • Utf8Builder: like StringBuilder, but for UTF8.
  • Utf8Writer: like StringBuilder, but for UTF8 and writing to a Stream that you provide.

The major caveat when working with utf8: if you forge a utf8 instance from a mutable byte buffer, you must clone it before altering the buffer. Since it doesn't copy the data by default, changes in the underlying buffer are changes in the string!

Real-world results

The test project is a compiler that turns a markdown-ish format into epub documents. When using System.String to compile the 413KB reference document, run time took 1.02 seconds and allocated 3.8GB of String objects.

When using StringView, the run time was reduced to 0.12 seconds and allocations were reduced to 3.8MB of String objects. Other allocations were not significantly changed.

When using utf8, the run time was reduced to 0.03 seconds. String allocations were reduced to 300KB. Other allocations were slightly reduced: System.Char[] allocations were converted to System.Byte[] and dropped by 300KB.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].