All Projects → MengRao → Str

MengRao / Str

Licence: mit
A SIMD optimized fixed-length string class along with an adaptive hash table for fast searching

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Str

memchr
Optimized string search routines for Rust.
Stars: ✭ 474 (+690%)
Mutual labels:  string, simd
Litestringbuilder
Alternative to the System.Text.StringBuilder C# class.
Stars: ✭ 48 (-20%)
Mutual labels:  string
Xformat
Multi-syntax printf
Stars: ✭ 8 (-86.67%)
Mutual labels:  string
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-41.67%)
Mutual labels:  string
Quadray Engine
Realtime raytracer using SIMD on ARM, MIPS, PPC and x86
Stars: ✭ 13 (-78.33%)
Mutual labels:  simd
Kfr
Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Stars: ✭ 985 (+1541.67%)
Mutual labels:  simd
Compressed Vec
SIMD Floating point and integer compressed vector library
Stars: ✭ 25 (-58.33%)
Mutual labels:  simd
Golang Combinations
Golang library which provide an algorithm to generate all combinations out of a given string array.
Stars: ✭ 51 (-15%)
Mutual labels:  string
Simde
Implementations of SIMD instruction sets for systems which don't natively support them.
Stars: ✭ 1,012 (+1586.67%)
Mutual labels:  simd
Arccstr
Thread-safe, reference-counted null-terminated immutable Rust strings.
Stars: ✭ 34 (-43.33%)
Mutual labels:  string
Xsimd
C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)
Stars: ✭ 964 (+1506.67%)
Mutual labels:  simd
Libsimdpp
Portable header-only C++ low level SIMD library
Stars: ✭ 914 (+1423.33%)
Mutual labels:  simd
Vc
SIMD Vector Classes for C++
Stars: ✭ 985 (+1541.67%)
Mutual labels:  simd
Directxmath
DirectXMath is an all inline SIMD C++ linear algebra library for use in games and graphics apps
Stars: ✭ 859 (+1331.67%)
Mutual labels:  simd
Tinystr
A small ASCII-only bounded length string representation.
Stars: ✭ 48 (-20%)
Mutual labels:  string
Stringplus
Funny and minimal string library for C++ inspired by underscore.string
Stars: ✭ 7 (-88.33%)
Mutual labels:  string
Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-53.33%)
Mutual labels:  string
Parallel Xxhash
Compute xxHash hash codes for 8 keys in parallel
Stars: ✭ 36 (-40%)
Mutual labels:  simd
Cape
String encryption for Arduino, limited microcontrollers and other embedded systems.
Stars: ✭ 58 (-3.33%)
Mutual labels:  string
Xible
Visualize your workflow
Stars: ✭ 49 (-18.33%)
Mutual labels:  string

Str

Str is a char array wrapper providing some frequently used operations in the most efficient way(supporting AVX512 SIMD optimization), including string comparisons and conversion to/from integers.

StrHash

StrHash is an adaptive open addressing hash table template taking Str as key and providing a find function in the most efficient way. It's adaptive in that it can extract features from the keys contained in the table and train its hashing parameters dynamically to distribute the keys for avoiding collision.

StrHash is actually a subclass of std::map, so user can use whatever funcitons it provides to modify the table, and then call doneModify to train the table and fastFind to find keys in the table. Note that doneModify is pretty slow so it's not efficient to modify the table frequently between fastFind. It's recommended that clear be called immediately after doneModify if only fastFind is needed afterwards, so some memory can be saved.

StrHash currently supports 7 hash functions and one of which can be selected using template parameter HashFunc:

  • 0: djb ver1(default)
  • 1: djb ver2
  • 2: sax
  • 3: fnv
  • 4: oat
  • 5: murmur
  • 6: int(for integer keys)

User can also add other hash functions himself.

StrHash is also suitable to have integers(such as uint32_t or uint64_t) as key for searching. Define StrHash<8, Value, NullV, 6> for uint64_t and StrHash<4, Value, NullV, 6> for uint32_t, see benchfindint.cc for detailed usage.

Benchmark

Tests show that StrHash is 7x faster than std::unordered_map and 3x faster than other open addressing hash table implementations such as tsl::hopscotch_map and tsl::robin_map.

Str's operator== and compare is 2x faster than strncmp/memcmp or those of std::string.

Str's fromi and toi is 10x faster than stoi/strtol/to_string/sprintf.

benchfindstr.cc tests the performance of multiple string search solutions using the same data set. The data set contains the KRX option issue codes of Feb 2019 that we are interested in and are to be inserted into the table, and the first 1000 option issue codes we received from the market data(which are mostly of Feb 2019 but some are of other months) and are to be searched in the table. In benchfindstr.cc:

  • bench_hash<0~5> compair the performance of different hash functions StrHash supports.
  • bench_hash vs other searching solutions shows how StrHash is faster than others.
  • bench_map vs bench_string_map and bench_bsearch vs bench_string_bsearch show how Str is faster than std::string.

benchfindint.cc tests the performance of multiple integer search solutions in similar way to benchfindstr.cc. The data set contains the SHFE instrument No of type uint64_t. Here bench_hash6 should be the most suitable method.

benchcmp.cc tests string comparison operations.

benchnum.cc tests conversions to/from integers.

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].