mirror of https://github.com/orefkov/simstr.git
Release 1.4.0
- Make compatible with std strings. - Update docs. - Fix many errors.
This commit is contained in:
parent
de7461dcd5
commit
c278fb8f2b
|
|
@ -5,7 +5,7 @@ include(FetchContent)
|
|||
|
||||
project(
|
||||
simstr
|
||||
VERSION 1.3.1
|
||||
VERSION 1.4.0
|
||||
DESCRIPTION "Yet another modern C++ string library"
|
||||
HOMEPAGE_URL "https://github.com/orefkov/simstr"
|
||||
LANGUAGES CXX
|
||||
|
|
@ -115,13 +115,17 @@ if(SIMSTR_BUILD_TESTS)
|
|||
FetchContent_Declare(
|
||||
googletest
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
|
||||
FIND_PACKAGE_ARGS NAMES GTest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/v1.17.0.zip
|
||||
FIND_PACKAGE_ARGS NAMES GTest 1.17.0
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt FALSE CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
add_subdirectory(tests)
|
||||
if(TARGET gtest)
|
||||
target_compile_features(gtest PUBLIC cxx_std_23)
|
||||
target_compile_features(gtest_main PUBLIC cxx_std_23)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(GBencmark)
|
||||
|
|
@ -130,7 +134,7 @@ function(GBencmark)
|
|||
googlebench
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/benchmark/archive/refs/tags/v1.9.4.zip
|
||||
FIND_PACKAGE_ARGS NAMES benchmark
|
||||
FIND_PACKAGE_ARGS NAMES benchmark 1.9.4
|
||||
)
|
||||
set(BENCHMARK_ENABLE_TESTING OFF)
|
||||
set(BENCHMARK_ENABLE_LTO OFF)
|
||||
|
|
@ -140,7 +144,9 @@ function(GBencmark)
|
|||
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
|
||||
add_compile_definitions(BENCHMARK_STATIC_DEFINE)
|
||||
FetchContent_MakeAvailable(googlebench)
|
||||
target_compile_features(benchmark PUBLIC cxx_std_20)
|
||||
if(TARGET benchmark)
|
||||
target_compile_features(benchmark PUBLIC cxx_std_23)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
# Свежий Clang в Emscripten ругается на __COUNTER__
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ cmake_minimum_required (VERSION 3.15)
|
|||
|
||||
add_executable(benchStr bench_str.cpp bench.h)
|
||||
target_link_libraries(benchStr simstr::simstr benchmark::benchmark)
|
||||
target_compile_features(benchStr PUBLIC cxx_std_23)
|
||||
|
||||
add_executable(process_result process_result.cpp)
|
||||
target_link_libraries(process_result simstr_simstr)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,318 @@ using namespace std::literals;
|
|||
|
||||
void __(benchmark::State& state) { for (auto _: state) {} }
|
||||
|
||||
void ConcatStdToStd(benchmark::State& state) {
|
||||
std::string s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
std::string str = s1 + std::to_string(i) + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConcatSimToStd(benchmark::State& state) {
|
||||
std::string s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
std::string str = +s1 + i + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConcatSimToSim(benchmark::State& state) {
|
||||
stra s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
stringa str = s1 + i + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Concatenate string + Number + \"Literal\" ---------")->Repetitions(1);
|
||||
BENCHMARK(ConcatStdToStd) ->Name("Concat std::string and number by std to std::string");
|
||||
BENCHMARK(ConcatSimToStd) ->Name("Concat std::string and number by StrExpr to std::string");
|
||||
BENCHMARK(ConcatSimToSim) ->Name("Concat stringa and number by StrExpr to simstr::stringa");
|
||||
|
||||
void ConcatStdToStdHex(benchmark::State& state) {
|
||||
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
|
||||
std::string s1 = "art ";
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
// What is standard method to get hex number?
|
||||
std::string str = s1 + std::format("0x{:x}", i) + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ConcatSimToStdHex(benchmark::State& state) {
|
||||
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
|
||||
std::string s1 = "art ";
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
std::string str = +s1 + e_hex<HexFlags::Short>(i) + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConcatSimToSimHex(benchmark::State& state) {
|
||||
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
|
||||
stra s1 = "art ";
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
stringa str = s1 + e_hex<HexFlags::Short>(i) + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Concatenate string + Hex Number + \"Literal\" ---------")->Repetitions(1);
|
||||
BENCHMARK(ConcatStdToStdHex) ->Name("Concat std::string and hex number by std to std::string");
|
||||
BENCHMARK(ConcatSimToStdHex) ->Name("Concat std::string and hex number by StrExpr to std::string");
|
||||
BENCHMARK(ConcatSimToSimHex) ->Name("Concat stringa and hex number by StrExpr to simstr::stringa");
|
||||
|
||||
void ConcatStdToStdS(benchmark::State& state) {
|
||||
std::string s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
std::string str = s1 + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConcatSimToStdS(benchmark::State& state) {
|
||||
std::string s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
std::string str = +s1 + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConcatSimToSimS(benchmark::State& state) {
|
||||
stra s1 = "start ";
|
||||
for (auto _: state) {
|
||||
for (int i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
stringa str = s1 + " end";
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Concatenate string + \"Literal\" ---------")->Repetitions(1);
|
||||
BENCHMARK(ConcatStdToStdS) ->Name("Concat std::string by std to std::string");
|
||||
BENCHMARK(ConcatSimToStdS) ->Name("Concat std::string by StrExpr to std::string");
|
||||
BENCHMARK(ConcatSimToSimS) ->Name("Concat stringa by StrExpr to stringa");
|
||||
|
||||
size_t find_pos_str(std::string_view src, std::string_view name) {
|
||||
// before C++26 we can not concatenate string and string_view...
|
||||
return src.find("\n- "s + std::string{name} + " -\n");
|
||||
}
|
||||
|
||||
size_t find_pos_exp(ssa src, ssa name) {
|
||||
return src.find(std::string{"\n- " + name + " -\n"});
|
||||
}
|
||||
|
||||
size_t find_pos_sim(ssa src, ssa name) {
|
||||
return src.find(lstringa<200>{"\n- " + name + " -\n"});
|
||||
}
|
||||
|
||||
//> size_t find_pos_str(std::string_view src, std::string_view name) {
|
||||
void FindConcatThreeStr(benchmark::State& state) {
|
||||
std::string_view src = "sdfsdf\n- testtesttesttesttesttesttestte -\nsfrgdgfsg";
|
||||
std::string_view fnd = "testtesttesttesttesttesttestte";
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(src);
|
||||
benchmark::DoNotOptimize(fnd);
|
||||
size_t pos = find_pos_str(src, fnd);
|
||||
benchmark::DoNotOptimize(pos);
|
||||
#ifdef CHECK_RESULT
|
||||
if (pos != 6) {
|
||||
state.SkipWithError("fail");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//> size_t find_pos_exp(ssa src, ssa name) {
|
||||
void FindConcatThreeExp(benchmark::State& state) {
|
||||
std::string_view src = "sdfsdf\n- testtesttesttesttesttesttestte -\nsfrgdgfsg";
|
||||
std::string_view fnd = "testtesttesttesttesttesttestte";
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(src);
|
||||
benchmark::DoNotOptimize(fnd);
|
||||
size_t pos = find_pos_exp(src, fnd);
|
||||
benchmark::DoNotOptimize(pos);
|
||||
#ifdef CHECK_RESULT
|
||||
if (pos != 6) {
|
||||
state.SkipWithError("fail");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//> size_t find_pos_sim(ssa src, ssa name) {
|
||||
void FindConcatThreeSim(benchmark::State& state) {
|
||||
ssa src = "sdfsdf\n- testtesttesttesttesttesttestte -\nsfrgdgfsg";
|
||||
ssa fnd = "testtesttesttesttesttesttestte";
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(src);
|
||||
benchmark::DoNotOptimize(fnd);
|
||||
size_t pos = find_pos_sim(src, fnd);
|
||||
benchmark::DoNotOptimize(pos);
|
||||
#ifdef CHECK_RESULT
|
||||
if (pos != 6) {
|
||||
state.SkipWithError("fail");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Find three concatenated string in string_view -----")->Repetitions(1);
|
||||
BENCHMARK(FindConcatThreeStr)->Name("Find concat three std::string");
|
||||
BENCHMARK(FindConcatThreeExp)->Name("Find concat three strexpr");
|
||||
BENCHMARK(FindConcatThreeSim)->Name("Find concat three simstr");
|
||||
|
||||
|
||||
std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
|
||||
std::string res{type_name};
|
||||
if (prec) {
|
||||
res += "(" + std::to_string(prec);
|
||||
if (scale) {
|
||||
res += "," + std::to_string(scale);
|
||||
}
|
||||
res += ")";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
|
||||
stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
|
||||
//> std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
|
||||
void BuildTypeNameStr(benchmark::State& state) {
|
||||
std::string_view type_name = "numeric";
|
||||
size_t prec = state.range(0), scale = prec / 2;
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(type_name);
|
||||
benchmark::DoNotOptimize(prec);
|
||||
benchmark::DoNotOptimize(scale);
|
||||
std::string res = buildTypeNameStr(type_name, prec, scale);
|
||||
benchmark::DoNotOptimize(res);
|
||||
}
|
||||
}
|
||||
|
||||
//> std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
|
||||
void BuildTypeNameExp(benchmark::State& state) {
|
||||
std::string_view type_name = "numeric";
|
||||
size_t prec = state.range(0), scale = prec / 2;
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(type_name);
|
||||
benchmark::DoNotOptimize(prec);
|
||||
benchmark::DoNotOptimize(scale);
|
||||
std::string res = buildTypeNameExp(type_name, prec, scale);
|
||||
benchmark::DoNotOptimize(res);
|
||||
}
|
||||
}
|
||||
|
||||
//> stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
|
||||
void BuildTypeNameSim(benchmark::State& state) {
|
||||
ssa type_name = "numeric";
|
||||
size_t prec = state.range(0), scale = prec / 2;
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(type_name);
|
||||
benchmark::DoNotOptimize(prec);
|
||||
benchmark::DoNotOptimize(scale);
|
||||
stringa res = buildTypeNameSim(type_name, prec, scale);
|
||||
benchmark::DoNotOptimize(res);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Build Type Name ---------")->Repetitions(1);
|
||||
BENCHMARK(BuildTypeNameStr) ->Name("BuildTypeNameStr 0")->Arg(0);
|
||||
BENCHMARK(BuildTypeNameExp) ->Name("BuildTypeNameExp 0")->Arg(0);
|
||||
BENCHMARK(BuildTypeNameSim) ->Name("BuildTypeNameSim 0")->Arg(0);
|
||||
BENCHMARK(BuildTypeNameStr) ->Name("BuildTypeNameStr 10")->Arg(10);
|
||||
BENCHMARK(BuildTypeNameExp) ->Name("BuildTypeNameExp 10")->Arg(10);
|
||||
BENCHMARK(BuildTypeNameSim) ->Name("BuildTypeNameSim 10")->Arg(10);
|
||||
|
||||
std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
auto str_replace = [](std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
std::string result;
|
||||
for (size_t offset = 0; ;) {
|
||||
size_t pos = from.find(pattern, offset);
|
||||
if (pos == std::string::npos) {
|
||||
result += from.substr(offset);
|
||||
break;
|
||||
}
|
||||
result += from.substr(offset, pos - offset);
|
||||
result += repl;
|
||||
offset = pos + pattern.length();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return "<" + str_replace(from, pattern, repl) + ">";
|
||||
}
|
||||
|
||||
std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
return "<" + e_repl(from, pattern, repl) + ">";
|
||||
}
|
||||
|
||||
//> std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
void ReplaceStr(benchmark::State& state) {
|
||||
std::string_view from = "testitestitestitesti", what = "te", repl = "--+--";
|
||||
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(from);
|
||||
benchmark::DoNotOptimize(what);
|
||||
benchmark::DoNotOptimize(repl);
|
||||
std::string res = make_str_str(from, what, repl);
|
||||
benchmark::DoNotOptimize(res);
|
||||
}
|
||||
}
|
||||
|
||||
//> std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
void ReplaceExp(benchmark::State& state) {
|
||||
std::string_view from = "testitestitestitesti", what = "te", repl = "--+--";
|
||||
|
||||
for (auto _: state) {
|
||||
benchmark::DoNotOptimize(from);
|
||||
benchmark::DoNotOptimize(what);
|
||||
benchmark::DoNotOptimize(repl);
|
||||
std::string res = make_str_exp(from, what, repl);
|
||||
benchmark::DoNotOptimize(res);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(__)->Name("----- Replace string by copy -----")->Repetitions(1);
|
||||
BENCHMARK(ReplaceStr)->Name("Concat with replace str");
|
||||
BENCHMARK(ReplaceExp)->Name("Concat with replace exp");
|
||||
|
||||
template<typename T>
|
||||
void CreateEmpty(benchmark::State& state) {
|
||||
for (auto _: state) {
|
||||
|
|
@ -1861,7 +2173,7 @@ void BuildFuncNameSimStr(benchmark::State& state) {
|
|||
stringa res = f.f.build_full_name();
|
||||
benchmark::DoNotOptimize(res);
|
||||
#ifdef CHECK_RESULT
|
||||
if (res != stra{f.check}) {
|
||||
if (res != ssa{f.check}) {
|
||||
std::cout << res << "\n";
|
||||
state.SkipWithError("not equal");
|
||||
break;
|
||||
|
|
@ -1878,7 +2190,7 @@ void BuildFuncNameSimStr1(benchmark::State& state) {
|
|||
stringa res = f.f.build_full_name1();
|
||||
benchmark::DoNotOptimize(res);
|
||||
#ifdef CHECK_RESULT
|
||||
if (res != stra{f.check}) {
|
||||
if (res != ssa{f.check}) {
|
||||
std::cout << res << "\n";
|
||||
state.SkipWithError("not equal");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,27 @@
|
|||
- Concat stringa and number by StrExpr to simstr::stringa
|
||||
stringa в отличии от std::string,
|
||||
вмещает в SSO 23 символа вместо 15, поэтому
|
||||
в конце теста std::string приходится аллоцировать память,
|
||||
а в stringa весь тест входит в SSO.
|
||||
Unlike std::string, stringa
|
||||
holds 23 characters in SSO instead of 15, so
|
||||
at the end of the std::string test, memory has to be allocated,
|
||||
while in stringa , the entire test is included in SSO.
|
||||
|
||||
- Find concat three simstr
|
||||
Если результат конкатенации меньше 207 символов,
|
||||
он собирается в буфере на стеке, без аллокации и деалокации.
|
||||
If the concatenation result is less than 207 characters,
|
||||
it is collected in a stack-based buffer, without allocation or deallocation.
|
||||
|
||||
- Concat with replace exp
|
||||
В simstr строковое выражение для замены подстрок
|
||||
есть "из коробки".
|
||||
simstr has a string expression for replacing substrings out of the box.
|
||||
|
||||
- std::string e;
|
||||
Пустые строки, ничего необычного.
|
||||
Empty lines, nothing unusual.
|
||||
|
||||
- std::string_view e;
|
||||
- ssa e;
|
||||
|
|
@ -10,80 +32,111 @@
|
|||
- std::string e = "Test text";
|
||||
Короткий литерал помещается во внутренний буфер std::string,
|
||||
время тратится только на копирование 10 байтов.
|
||||
The short literal is placed in the internal std::string buffer;
|
||||
time is spent only copying 10 bytes.
|
||||
|
||||
- std::string_view e = "Test text";
|
||||
И string_view, и ssa - по сути одно и то же:
|
||||
указатель на текст и его длина.
|
||||
Both string_view and ssa are essentially the same thing:
|
||||
a pointer to text and its length.
|
||||
|
||||
- ssa e = "Test text";
|
||||
- stringa e = "Test text";
|
||||
stringa при инициализации константным литералом так же
|
||||
сохраняет только указатель на текст и его длину.
|
||||
When initialized with a constant literal, stringa also stores
|
||||
only a pointer to the text and its length.
|
||||
|
||||
- lstringa<20> e = "Test text";
|
||||
Внутреннего буфера хватает для размещения символов,
|
||||
время уходит только на копирование байтов.
|
||||
The internal buffer is sufficient to accommodate characters;
|
||||
time is spent only on copying bytes.
|
||||
|
||||
- lstringa<40> e = "Test text";
|
||||
- std::string e = "123456789012345678901234567890";
|
||||
Вот тут уже литерал не помещается во внутренний буфер,
|
||||
возникает аллокация и копирование 30-и байтов.
|
||||
Но как же отстает аллокация под Windows от Linux'а, 20 vs 70 ns...
|
||||
|
||||
Here, the literal doesn't fit into the internal buffer,
|
||||
and 30 bytes are allocated and copied.
|
||||
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...
|
||||
|
||||
- std::string_view e = "123456789012345678901234567890";
|
||||
string_view и ssa по прежнему ничего не делают, кроме
|
||||
запоминания указателя на текст и его размера.
|
||||
string_view and ssa still do nothing except
|
||||
remember the pointer to the text and its size.
|
||||
|
||||
- ssa e = "123456789012345678901234567890";
|
||||
- stringa e = "123456789012345678901234567890";
|
||||
stringa на константных литералах не отстает!
|
||||
stringa doesn't lag behind on constant literals!
|
||||
|
||||
- lstringa<20> e = "123456789012345678901234567890";
|
||||
lstringa<20> может вместить в себя до 23 символов,
|
||||
Очевидно, что для 30-и символов уже нужна аллокация.
|
||||
Obviously, 30 characters already require allocation.
|
||||
|
||||
- lstringa<40> e = "123456789012345678901234567890";
|
||||
А в lstringa<40> влезает до 47 символов, так что просто
|
||||
копируется 30 байтов.
|
||||
And lstringa<40> can hold up to 47 characters, so 30
|
||||
bytes are simply copied.
|
||||
|
||||
- std::string e = "Test text"; auto c{e};
|
||||
Строка в пределах SSO, так что просто копирует байты.
|
||||
The string is within the SSO, so it just copies the bytes.
|
||||
|
||||
- std::string_view e = "Test text"; auto c{e};
|
||||
- ssa e = "Test text"; auto c{e};
|
||||
ssa и string_view не владеют строкой, копируется
|
||||
только информация о строке.
|
||||
ssa and string_view don't own the string; only the
|
||||
string information is copied.
|
||||
|
||||
- stringa e = "Test text"; auto c{e};
|
||||
Копирование stringa происходит быстро,
|
||||
особенно если она инициализирована литералом.
|
||||
Copying a stringa is fast,
|
||||
especially if it is initialized with a literal.
|
||||
|
||||
- lstringa<20> e = "Test text"; auto c{e};
|
||||
В обоих случаях хватает внутреннего буфера.
|
||||
In both cases, the internal buffer is sufficient.
|
||||
|
||||
- lstringa<40> e = "Test text"; auto c{e};
|
||||
Только копируются байты.
|
||||
Only bytes are copied.
|
||||
|
||||
- std::string e = "123456789012345678901234567890"; auto c{e};
|
||||
Копирования длинной строки вызывает аллокацию,
|
||||
SSO уже не хватает. И снова как же отстаёт аллокация под Windows...
|
||||
Copying a long string causes allocations,
|
||||
SSO is no longer sufficient. And again, how allocation lags under Windows...
|
||||
|
||||
- std::string_view e = "123456789012345678901234567890"; auto c{e};
|
||||
- ssa e = "123456789012345678901234567890"; auto c{e};
|
||||
- stringa e = "123456789012345678901234567890"; auto c{e};
|
||||
А вот у stringa копирование литерала не зависит от его длины,
|
||||
сравни с предыдущим бенчмарком.
|
||||
But with stringa, literal copying doesn't depend on its length,
|
||||
compare with the previous benchmark.
|
||||
|
||||
- lstringa<20> e = "123456789012345678901234567890"; auto c{e};
|
||||
Не влезает, аллокация.
|
||||
Doesn't fit, allocation.
|
||||
|
||||
- lstringa<40> e = "123456789012345678901234567890"; auto c{e};
|
||||
Уложили во внутренний буфер.
|
||||
Placed in the internal buffer.
|
||||
|
||||
- std::string::find;
|
||||
Здесь "победила дружба", у всех типов по колонке примерно одинаково.
|
||||
Однако, Windows и Linux явно в разных весовых категориях.
|
||||
Here, "friendship wins," with all types scoring roughly equally.
|
||||
However, Windows and Linux are clearly in different weight classes.
|
||||
|
||||
- std::string_view::find;
|
||||
- ssa::find;
|
||||
|
|
@ -95,9 +148,13 @@ SSO уже не хватает. И снова как же отстаёт алл
|
|||
Явно виден скачок, где заканчивается SSO и начинается аллокация.
|
||||
Обратите внимание, что WASM - 32-битный, и там размер
|
||||
SSO у std::string меньше, насколько я помню, 11 символов + 0.
|
||||
The jump where SSO ends and allocation begins is clearly visible.
|
||||
Note that WASM is 32-bit, and the size of the SSO for std::string is
|
||||
smaller, as far as I remember: 11 characters + 0.
|
||||
|
||||
- std::string copy{str_with_len_N};/23
|
||||
Дальше просто добавляется время на копирование байтов.
|
||||
Then the time for copying bytes is simply added.
|
||||
|
||||
- std::string copy{str_with_len_N};/24
|
||||
- std::string copy{str_with_len_N};/32
|
||||
|
|
@ -109,23 +166,33 @@ SSO у std::string меньше, насколько я помню, 11 симво
|
|||
- std::string copy{str_with_len_N};/2048
|
||||
- std::string copy{str_with_len_N};/4096
|
||||
Чем длиннее строка, тем дольше создаётся копия.
|
||||
The longer the string, the longer it takes to create a copy.
|
||||
|
||||
- stringa copy{str_with_len_N};/15
|
||||
Здесь stringa инициализируется не литералом,
|
||||
а значит, должна сама хранить символы.
|
||||
Here, stringa is not initialized with a literal,
|
||||
meaning it must store characters itself.
|
||||
|
||||
- stringa copy{str_with_len_N};/16
|
||||
Под WASM SSO у stringa составляет 15 символов. Кроме того,
|
||||
собиралось без поддержки потоков, поэтому возможно атомарный
|
||||
собиралось без поддержки потоков, поэтому атомарный
|
||||
инкремент заменён на обычный, судя по времени.
|
||||
Under WASM, stringa has a 15-character SSO. Furthermore,
|
||||
it was built without thread support, so the atomic
|
||||
increment was replaced with a regular one, judging by the time.
|
||||
|
||||
- stringa copy{str_with_len_N};/23
|
||||
SSO в stringa до 23 символов, и даже 23
|
||||
копируются быстрее, чем 15 в std::string.
|
||||
SSO in stringa is up to 23 characters, and even 23
|
||||
copies faster than 15 in std::string.
|
||||
|
||||
- stringa copy{str_with_len_N};/24
|
||||
Всё, не влезаем в SSO, а значит, используем shared буфер.
|
||||
Добавляется время на атомарный инкремент счётчика.
|
||||
That's it, we're not using SSO, so we're using a shared buffer.
|
||||
Time is added for the atomic counter increment.
|
||||
|
||||
- stringa copy{str_with_len_N};/32
|
||||
- stringa copy{str_with_len_N};/64
|
||||
|
|
@ -137,15 +204,20 @@ SSO в stringa до 23 символов, и даже 23
|
|||
- stringa copy{str_with_len_N};/4096
|
||||
И как видно, кроме инкремента нет накладных расходов,
|
||||
время копирования не зависит от длины строки.
|
||||
And as you can see, there are no overhead costs other than the
|
||||
increment; copying time does not depend on the string length.
|
||||
|
||||
- lstringa<16> copy{str_with_len_N};/15
|
||||
lstringa<16> использует SSO до 23 символов.
|
||||
А в WASM 32-битная архитектура, SSO до 19 символов.
|
||||
lstringa<16> uses SSO up to 23 characters.
|
||||
WASM has a 32-bit architecture, so SSO is up to 19 characters.
|
||||
|
||||
- lstringa<16> copy{str_with_len_N};/16
|
||||
- lstringa<16> copy{str_with_len_N};/23
|
||||
- lstringa<16> copy{str_with_len_N};/24
|
||||
И после начинает вести себя при копировании, как std::string.
|
||||
And then it starts to behave like std::string when copied.
|
||||
|
||||
- lstringa<16> copy{str_with_len_N};/32
|
||||
- lstringa<16> copy{str_with_len_N};/64
|
||||
|
|
@ -158,6 +230,8 @@ lstringa<16> использует SSO до 23 символов.
|
|||
- lstringa<512> copy{str_with_len_N};/8
|
||||
А вот lstringa<512> имеет гораздо больший внутренний
|
||||
буфер и копирует символы без аллокации.
|
||||
But lstringa<512> has a much larger internal
|
||||
buffer and copies characters without allocation.
|
||||
|
||||
- lstringa<512> copy{str_with_len_N};/16
|
||||
- lstringa<512> copy{str_with_len_N};/32
|
||||
|
|
@ -167,9 +241,12 @@ lstringa<16> использует SSO до 23 символов.
|
|||
- lstringa<512> copy{str_with_len_N};/512
|
||||
Даже 512 символов копируются быстрее, чем
|
||||
одна аллокация или атомарный инкремент.
|
||||
Even 512 characters are copied faster than a single
|
||||
allocation or atomic increment.
|
||||
|
||||
- lstringa<512> copy{str_with_len_N};/1024
|
||||
А дальше уже как у всех
|
||||
А дальше уже как у всех.
|
||||
And then it's like everyone else.
|
||||
|
||||
- lstringa<512> copy{str_with_len_N};/2048
|
||||
- lstringa<512> copy{str_with_len_N};/4096
|
||||
|
|
@ -180,19 +257,28 @@ lstringa<16> использует SSO до 23 символов.
|
|||
поведения "std::from_chars", но он к сожалению очень ограничен
|
||||
по возможностям. Здесь я попытался произвести тесты, близкие по
|
||||
логике к работе std::from_chars
|
||||
In simstr, a string fragment is sufficient for conversion to a number;
|
||||
there's no need for null termination. The closest analog to this behavior
|
||||
is "std::from_chars," but unfortunately, it is very limited in its capabilities.
|
||||
Here, I attempted to run tests that are similar in logic to std::from_chars.
|
||||
|
||||
- std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);
|
||||
from_chars требует точного указания основания счисления,
|
||||
не допускает знаков плюс, пробелов, префиксов 0x и т.п.
|
||||
from_chars requires an exact radix specification and does not allow plus
|
||||
signs, spaces, 0x prefixes, etc.
|
||||
|
||||
- stringa s = "123456789"; int res = s.to_int<int, true, 10, false>
|
||||
Здесь для to_int заданы такие же ограничения - проверять переполнение,
|
||||
десятичная система, без лидирующих пробелов и знака плюс
|
||||
Here, to_int has the same restrictions: check for overflow,
|
||||
decimal system, no leading spaces, and no plus sign.
|
||||
|
||||
- ssa s = "123456789"; int res = s.to_int<int, true, 10, false>
|
||||
- lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>
|
||||
- std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);
|
||||
Всё то же, только для 16ричной системы
|
||||
Everything is the same, only for the hexadecimal system
|
||||
|
||||
- std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);
|
||||
- stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>
|
||||
|
|
@ -200,6 +286,7 @@ from_chars требует точного указания основания с
|
|||
- lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>
|
||||
- std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);
|
||||
А здесь уже парсинг произвольного числа.
|
||||
And here we have parsing of an arbitrary number.
|
||||
|
||||
- stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow
|
||||
- ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow
|
||||
|
|
@ -209,6 +296,8 @@ from_chars требует точного указания основания с
|
|||
- lstringa<128> str; ... str += "abbaabbaabbaabba";
|
||||
Чем больше внутренний буфер, тем меньше раз требуется
|
||||
аллокация, тем быстрее результат.
|
||||
The larger the internal buffer, the fewer allocations are
|
||||
required, and the faster the result.
|
||||
|
||||
- lstringa<512> str; ... str += "abbaabbaabbaabba";
|
||||
- lstringa<1024> str; ... str += "abbaabbaabbaabba";
|
||||
|
|
@ -236,20 +325,28 @@ from_chars требует точного указания основания с
|
|||
- std::string str = std::format("test = {} times", k);
|
||||
- lstringa<8> str; str.format("test = {} times", k);
|
||||
В simstr format с первого раза не помещается в такую строку без аллокации.
|
||||
In simstr format, the first time it doesn't fit into such a
|
||||
string without allocation.
|
||||
|
||||
- lstringa<32> str; str.format("test = {} times", k);
|
||||
А в такую помещается. Используйте сразу буфера подходящего размера.
|
||||
And it fits in this one. Use buffers of the appropriate size right away.
|
||||
|
||||
- lstringa<8> str = "test = " + k + " times";
|
||||
Результат не помещается в SSO, возникает аллокация.
|
||||
The result does not fit into SSO, an allocation occurs.
|
||||
|
||||
- lstringa<32> str = "test = " + k + " times";
|
||||
А здесь и ниже - результат укладывается в SSO.
|
||||
Ещё раз - используйте сразу буфера подходящего размера.
|
||||
And here and below, the result fits within SSO.
|
||||
Once again, use appropriately sized buffers from the start.
|
||||
|
||||
- stringa str = "test = " + k + " times";
|
||||
Под WASM размер SSO 15 символов, что явно не хватает для размещения
|
||||
результата, отсюда и такое время.
|
||||
Under WASM, the SSO size is 15 characters, which is clearly not
|
||||
enough to accommodate the result, hence the long time.
|
||||
|
||||
- std::string::find + substr + std::strtol
|
||||
- ssa::splitter + ssa::as_int
|
||||
|
|
@ -258,9 +355,14 @@ from_chars требует точного указания основания с
|
|||
Это наивная реализация, которая неверно отработает на
|
||||
таких заменах, как 'a'->'b' и 'b'->'a'. Но если замены не конфликтуют,
|
||||
то работает быстро.
|
||||
This is a naive implementation that will fail to handle substitutions
|
||||
such as 'a'->'b' and 'b'->'a'. But if the substitutions don't conflict,
|
||||
it works quickly.
|
||||
|
||||
- replace symbols with std::string find_first_of + replace
|
||||
Дальше уже правильные реализации, не зависящие от конфликтующих замен.
|
||||
Further, there are correct implementations that do not depend on
|
||||
conflicting replacements.
|
||||
|
||||
- replace symbols with std::string_view find_first_of + copy
|
||||
- replace runtime symbols with string expressions and without remembering all search results
|
||||
|
|
@ -278,6 +380,8 @@ from_chars требует точного указания основания с
|
|||
- replace bb to ---- in 64 std::string
|
||||
Тут проверяется тяжелый случай - замена подстроки на более
|
||||
длинную. Обычная реализация несколько раз передвигает хвост.
|
||||
This checks for a difficult case: replacing a substring with a longer
|
||||
one. The standard implementation moves the tail several times.
|
||||
|
||||
- replace bb to ---- in 64 lstringa<8>
|
||||
- replace bb to ---- in 64 str by init stringa
|
||||
|
|
@ -292,11 +396,13 @@ from_chars требует точного указания основания с
|
|||
- replace bb to ---- in 1024 str by init stringa
|
||||
- replace bb to ---- in 2048 std::string
|
||||
Чем длиннее строка, тем больше замедляется std::string
|
||||
The longer the string, the slower std::string becomes.
|
||||
|
||||
- replace bb to ---- in 2048 lstringa<8>
|
||||
- replace bb to ---- in 2048 str by init stringa
|
||||
- replace bb to -- in 64 std::string
|
||||
Идеальный случай замены - на подстроку такой же длины
|
||||
The ideal case of replacement is with a substring of the same length.
|
||||
|
||||
- replace bb to -- in 64 lstringa<8>
|
||||
- replace bb to -- in 64 by init stringa
|
||||
|
|
@ -315,37 +421,55 @@ from_chars требует точного указания основания с
|
|||
- hashStrMapA<size_t> emplace & find stringa;
|
||||
Вставляем в hashStrMapA 10000 stringa длиной от 30 до 50
|
||||
символов, а потом ищем их в ней
|
||||
We insert 10,000 strings of length from 30 to 50 characters into
|
||||
hashStrMapA, and then search for them in it.
|
||||
|
||||
- std::unordered_map<std::string, size_t> emplace & find std::string;
|
||||
То же самое c std::string и std::unordered_map
|
||||
Same thing with std::string and std::unordered_map
|
||||
|
||||
- hashStrMapA<size_t> emplace & find ssa;
|
||||
Теперь вставляем stringa, а ищем ssa
|
||||
Now we insert stringa and search for ssa
|
||||
|
||||
- std::unordered_map<std::string, size_t> emplace & find std::string_view;
|
||||
Вставляем std::string, а ищем std::string_view
|
||||
We insert std::string and look for std::string_view
|
||||
|
||||
- Build func full name std::string;
|
||||
Обыденная задача, подобные часто могут встретится в работе:
|
||||
По неким данным сгенерировать текст. В этом случае по данным
|
||||
о неких функциях сформировать их полное имя с типами параметров и
|
||||
возвращаемого значения. Алгоритм на std::string.
|
||||
A common task, similar to this one, can often be encountered in work:
|
||||
Generate text from given data. In this case, using data
|
||||
on certain functions, generate their full names with parameter types and
|
||||
return values. The algorithm uses std::string.
|
||||
|
||||
- Build func full name std::string 1;
|
||||
Почти тот же алгоритм, но несколько последовательных
|
||||
+= к строке заменены на одно += + + +.
|
||||
Almost the same algorithm, but several consecutive
|
||||
+= to a string are replaced with a single += + + +.
|
||||
|
||||
- Build func full name std::stream;
|
||||
Строим имя функции через std::ostringstream и <<
|
||||
We construct the function name through std::ostringstream and <<
|
||||
|
||||
- Build func full name stringa;
|
||||
Реализация на simstr строках и строковых выражениях.
|
||||
Инфа о параметрах добавляется в текущую строку
|
||||
Implementation using simstr strings and string expressions.
|
||||
Parameter information is appended to the current line.
|
||||
|
||||
- Build func full name stringa 1;
|
||||
Реализация на simstr строках и строковых выражениях.
|
||||
Инфа о параметрах добавляется во временную строку, а потом
|
||||
разом добавляется в текущую строку. Позволяет операции в цикле
|
||||
записать в одну строку, но чуть проигрывает по времени выполнения.
|
||||
Implementation using simstr strings and string expressions.
|
||||
Parameter information is added to a temporary string, and then
|
||||
all at once to the current string. This allows loop operations
|
||||
to be written in a single string, but is slightly slower in execution time.
|
||||
|
||||
- Пусто
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ bool extract_cpu_info(ssa text, ssa& res) {
|
|||
struct result_info {
|
||||
stringa text_;
|
||||
stringa platform_;
|
||||
ssa current_text_{text_};
|
||||
ssa current_text_ = text_.to_str();
|
||||
ssa cpu_info_;
|
||||
|
||||
result_info(stringa text, stringa platform) : text_(std::move(text)), platform_(std::move(platform)) {
|
||||
|
|
@ -94,9 +94,9 @@ results_vector get_results_infos() {
|
|||
ssa fileName = f;
|
||||
// В начале имени файла может идти число и дефис, для сортировки, уберём их
|
||||
// At the beginning of the file name there can be a number and a hyphen, for sorting, remove them
|
||||
if (auto delimeter = fileName.find('-'); delimeter + 1 > 1) {
|
||||
if (fileName(0, delimeter).to_int<unsigned, false, 10, false, false>().ec == IntConvertResult::Success) {
|
||||
fileName.remove_prefix(delimeter + 1);
|
||||
if (auto delimiter = fileName.find('-'); delimiter + 1 > 1) {
|
||||
if (fileName(0, delimiter).to_int<unsigned, false, 10, false, false>().ec == IntConvertResult::Success) {
|
||||
fileName.remove_prefix(delimiter + 1);
|
||||
}
|
||||
}
|
||||
results.emplace_back(get_file_content(lstringa<128>{dirForResults + f}), fileName(0, -suffix.length()));
|
||||
|
|
@ -129,9 +129,19 @@ auto repl_html_symbols(ssa text) {
|
|||
return e_repl_const_symbols(text, '\"', """, '<', "<", '\'', "'", '&', "&");
|
||||
}
|
||||
|
||||
void write_benchset_header(out_t& out, const results_vector& results, ssa benchsetName, unsigned id) {
|
||||
void write_benchset_header(out_t& out, const results_vector& results, ssa benchsetName, unsigned benchSetId) {
|
||||
size_t hash = fnv_hash(benchsetName.symbols(), benchsetName.length());
|
||||
static std::unordered_map<size_t, int> ids;
|
||||
auto [id, _] = ids.try_emplace(hash, 0);
|
||||
if (id->second) {
|
||||
std::cout << "Duplicate hash for " << benchsetName << "\n";
|
||||
}
|
||||
int ii = id->second++;
|
||||
|
||||
size_t width = 40 / results.size();
|
||||
out += "\n\n<div class=\"benchset\" id=\"bs"_ss + id + "\"><h4>" + repl_html_symbols(benchsetName) + "</h4>\n<table><thead><tr><th>Benchmark name</th><th width=\"5%\">Comment</th>";
|
||||
out += "\n\n<div class=\"benchset\" id=\"bs"_ss + benchSetId + "\"><h4><a id=\"bs" + hash + ii + "\" href=\"#bs" +
|
||||
hash + ii + "\">#</a> " + repl_html_symbols(benchsetName) +
|
||||
"</h4>\n<table><thead><tr><th>Benchmark name</th><th width=\"5%\">Comment</th>";
|
||||
for (const auto& r : results) {
|
||||
out += "<th width=\""_ss + width + "%\">" + r.platform_ + "</th>";
|
||||
}
|
||||
|
|
@ -184,6 +194,9 @@ void write_one_result(out_t& out, ssa result, ssa line, auto& script_text, bool
|
|||
}
|
||||
|
||||
ssa extract_source_for_benchmark(ssa benchName, ssa sourceText) {
|
||||
if (benchName == "ReplaceStr") {
|
||||
int t = 0;
|
||||
}
|
||||
static hashStrMapA<stringa> textes;
|
||||
|
||||
size_t delim = benchName.find_last('/');
|
||||
|
|
|
|||
1236
bench/results.html
1236
bench/results.html
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,784 +0,0 @@
|
|||
Run on (32 X 2513.96 MHz CPU s)
|
||||
Chromium: 142.0.7444.60 webasm
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Benchmark Time CPU Iterations
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
----- Create Empty Str ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e;_mean 5.87 ns 5.87 ns 10
|
||||
std::string e;_median 5.83 ns 5.83 ns 10
|
||||
std::string e;_stddev 0.100 ns 0.100 ns 10
|
||||
std::string e;_cv 1.71 % 1.71 % 10
|
||||
std::string_view e;_mean 5.26 ns 5.26 ns 10
|
||||
std::string_view e;_median 5.26 ns 5.26 ns 10
|
||||
std::string_view e;_stddev 0.022 ns 0.022 ns 10
|
||||
std::string_view e;_cv 0.43 % 0.43 % 10
|
||||
ssa e;_mean 4.67 ns 4.67 ns 10
|
||||
ssa e;_median 4.67 ns 4.67 ns 10
|
||||
ssa e;_stddev 0.023 ns 0.023 ns 10
|
||||
ssa e;_cv 0.50 % 0.49 % 10
|
||||
stringa e;_mean 4.82 ns 4.82 ns 10
|
||||
stringa e;_median 4.81 ns 4.81 ns 10
|
||||
stringa e;_stddev 0.040 ns 0.040 ns 10
|
||||
stringa e;_cv 0.83 % 0.83 % 10
|
||||
lstringa<20> e;_mean 4.64 ns 4.64 ns 10
|
||||
lstringa<20> e;_median 4.62 ns 4.62 ns 10
|
||||
lstringa<20> e;_stddev 0.076 ns 0.076 ns 10
|
||||
lstringa<20> e;_cv 1.63 % 1.63 % 10
|
||||
lstringa<40> e;_mean 4.76 ns 4.76 ns 10
|
||||
lstringa<40> e;_median 4.72 ns 4.72 ns 10
|
||||
lstringa<40> e;_stddev 0.128 ns 0.128 ns 10
|
||||
lstringa<40> e;_cv 2.68 % 2.68 % 10
|
||||
----- Create Str from short literal (9 symbols) --------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "Test text";_mean 5.17 ns 5.17 ns 10
|
||||
std::string e = "Test text";_median 5.16 ns 5.16 ns 10
|
||||
std::string e = "Test text";_stddev 0.060 ns 0.060 ns 10
|
||||
std::string e = "Test text";_cv 1.16 % 1.16 % 10
|
||||
std::string_view e = "Test text";_mean 5.57 ns 5.57 ns 10
|
||||
std::string_view e = "Test text";_median 5.56 ns 5.56 ns 10
|
||||
std::string_view e = "Test text";_stddev 0.026 ns 0.026 ns 10
|
||||
std::string_view e = "Test text";_cv 0.47 % 0.47 % 10
|
||||
ssa e = "Test text";_mean 3.41 ns 3.41 ns 10
|
||||
ssa e = "Test text";_median 3.41 ns 3.41 ns 10
|
||||
ssa e = "Test text";_stddev 0.029 ns 0.029 ns 10
|
||||
ssa e = "Test text";_cv 0.84 % 0.84 % 10
|
||||
stringa e = "Test text";_mean 5.07 ns 5.07 ns 10
|
||||
stringa e = "Test text";_median 5.01 ns 5.01 ns 10
|
||||
stringa e = "Test text";_stddev 0.168 ns 0.168 ns 10
|
||||
stringa e = "Test text";_cv 3.32 % 3.32 % 10
|
||||
lstringa<20> e = "Test text";_mean 5.37 ns 5.37 ns 10
|
||||
lstringa<20> e = "Test text";_median 5.37 ns 5.37 ns 10
|
||||
lstringa<20> e = "Test text";_stddev 0.102 ns 0.102 ns 10
|
||||
lstringa<20> e = "Test text";_cv 1.90 % 1.90 % 10
|
||||
lstringa<40> e = "Test text";_mean 5.37 ns 5.37 ns 10
|
||||
lstringa<40> e = "Test text";_median 5.36 ns 5.36 ns 10
|
||||
lstringa<40> e = "Test text";_stddev 0.061 ns 0.061 ns 10
|
||||
lstringa<40> e = "Test text";_cv 1.13 % 1.13 % 10
|
||||
----- Create Str from long literal (30 symbols) ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "123456789012345678901234567890";_mean 63.4 ns 63.4 ns 10
|
||||
std::string e = "123456789012345678901234567890";_median 63.5 ns 63.5 ns 10
|
||||
std::string e = "123456789012345678901234567890";_stddev 2.12 ns 2.12 ns 10
|
||||
std::string e = "123456789012345678901234567890";_cv 3.35 % 3.35 % 10
|
||||
std::string_view e = "123456789012345678901234567890";_mean 5.58 ns 5.58 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_median 5.57 ns 5.57 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_stddev 0.045 ns 0.045 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_cv 0.81 % 0.81 % 10
|
||||
ssa e = "123456789012345678901234567890";_mean 3.33 ns 3.33 ns 10
|
||||
ssa e = "123456789012345678901234567890";_median 3.33 ns 3.33 ns 10
|
||||
ssa e = "123456789012345678901234567890";_stddev 0.026 ns 0.026 ns 10
|
||||
ssa e = "123456789012345678901234567890";_cv 0.78 % 0.78 % 10
|
||||
stringa e = "123456789012345678901234567890";_mean 4.95 ns 4.95 ns 10
|
||||
stringa e = "123456789012345678901234567890";_median 4.90 ns 4.90 ns 10
|
||||
stringa e = "123456789012345678901234567890";_stddev 0.103 ns 0.103 ns 10
|
||||
stringa e = "123456789012345678901234567890";_cv 2.08 % 2.08 % 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_mean 63.1 ns 63.1 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_median 63.0 ns 63.0 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_stddev 2.03 ns 2.03 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_cv 3.22 % 3.22 % 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_mean 5.86 ns 5.86 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_median 5.90 ns 5.90 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_stddev 0.090 ns 0.090 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_cv 1.53 % 1.53 % 10
|
||||
----- Create copy of Str with 9 symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "Test text"; auto c{e};_mean 11.0 ns 11.0 ns 10
|
||||
std::string e = "Test text"; auto c{e};_median 11.0 ns 11.0 ns 10
|
||||
std::string e = "Test text"; auto c{e};_stddev 0.061 ns 0.061 ns 10
|
||||
std::string e = "Test text"; auto c{e};_cv 0.55 % 0.55 % 10
|
||||
std::string_view e = "Test text"; auto c{e};_mean 5.91 ns 5.91 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_median 5.91 ns 5.91 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_stddev 0.014 ns 0.014 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_cv 0.24 % 0.24 % 10
|
||||
ssa e = "Test text"; auto c{e};_mean 6.84 ns 6.84 ns 10
|
||||
ssa e = "Test text"; auto c{e};_median 6.85 ns 6.85 ns 10
|
||||
ssa e = "Test text"; auto c{e};_stddev 0.043 ns 0.043 ns 10
|
||||
ssa e = "Test text"; auto c{e};_cv 0.62 % 0.62 % 10
|
||||
stringa e = "Test text"; auto c{e};_mean 5.18 ns 5.18 ns 10
|
||||
stringa e = "Test text"; auto c{e};_median 5.15 ns 5.15 ns 10
|
||||
stringa e = "Test text"; auto c{e};_stddev 0.150 ns 0.150 ns 10
|
||||
stringa e = "Test text"; auto c{e};_cv 2.90 % 2.90 % 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_mean 17.5 ns 17.5 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_median 17.5 ns 17.5 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_stddev 0.608 ns 0.608 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_cv 3.48 % 3.48 % 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_mean 17.4 ns 17.4 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_median 17.5 ns 17.5 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_stddev 0.419 ns 0.419 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_cv 2.40 % 2.40 % 10
|
||||
----- Create copy of Str with 30 symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_mean 93.3 ns 93.3 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_median 92.5 ns 92.5 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_stddev 3.13 ns 3.13 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_cv 3.35 % 3.35 % 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_mean 5.57 ns 5.57 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_median 5.57 ns 5.57 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_stddev 0.019 ns 0.019 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_cv 0.35 % 0.35 % 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_mean 3.32 ns 3.32 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_median 3.32 ns 3.32 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_stddev 0.021 ns 0.021 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_cv 0.63 % 0.63 % 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_mean 4.89 ns 4.89 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_median 4.87 ns 4.87 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_stddev 0.063 ns 0.063 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_cv 1.30 % 1.30 % 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_mean 66.3 ns 66.3 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_median 66.0 ns 66.1 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_stddev 2.64 ns 2.64 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_cv 3.98 % 3.98 % 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_mean 17.0 ns 17.0 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_median 16.7 ns 16.7 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_stddev 0.960 ns 0.960 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_cv 5.66 % 5.66 % 10
|
||||
----- Find 9 symbols text in end of 99 symbols text ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string::find;_mean 101 ns 101 ns 10
|
||||
std::string::find;_median 101 ns 101 ns 10
|
||||
std::string::find;_stddev 1.61 ns 1.61 ns 10
|
||||
std::string::find;_cv 1.59 % 1.59 % 10
|
||||
std::string_view::find;_mean 103 ns 103 ns 10
|
||||
std::string_view::find;_median 102 ns 102 ns 10
|
||||
std::string_view::find;_stddev 4.97 ns 4.97 ns 10
|
||||
std::string_view::find;_cv 4.83 % 4.83 % 10
|
||||
ssa::find;_mean 102 ns 102 ns 10
|
||||
ssa::find;_median 102 ns 102 ns 10
|
||||
ssa::find;_stddev 2.15 ns 2.15 ns 10
|
||||
ssa::find;_cv 2.11 % 2.11 % 10
|
||||
stringa::find;_mean 105 ns 105 ns 10
|
||||
stringa::find;_median 104 ns 104 ns 10
|
||||
stringa::find;_stddev 4.34 ns 4.34 ns 10
|
||||
stringa::find;_cv 4.15 % 4.15 % 10
|
||||
lstringa<20>::find;_mean 99.9 ns 99.9 ns 10
|
||||
lstringa<20>::find;_median 99.9 ns 99.9 ns 10
|
||||
lstringa<20>::find;_stddev 1.61 ns 1.61 ns 10
|
||||
lstringa<20>::find;_cv 1.61 % 1.61 % 10
|
||||
lstringa<40>::find;_mean 100 ns 100 ns 10
|
||||
lstringa<40>::find;_median 99.2 ns 99.2 ns 10
|
||||
lstringa<40>::find;_stddev 3.67 ns 3.67 ns 10
|
||||
lstringa<40>::find;_cv 3.66 % 3.66 % 10
|
||||
------- Copy not literal Str with N symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string copy{str_with_len_N};/15_mean 97.2 ns 97.2 ns 10
|
||||
std::string copy{str_with_len_N};/15_median 98.2 ns 98.2 ns 10
|
||||
std::string copy{str_with_len_N};/15_stddev 5.39 ns 5.39 ns 10
|
||||
std::string copy{str_with_len_N};/15_cv 5.55 % 5.55 % 10
|
||||
std::string copy{str_with_len_N};/16_mean 94.6 ns 94.6 ns 10
|
||||
std::string copy{str_with_len_N};/16_median 95.7 ns 95.7 ns 10
|
||||
std::string copy{str_with_len_N};/16_stddev 3.09 ns 3.09 ns 10
|
||||
std::string copy{str_with_len_N};/16_cv 3.27 % 3.27 % 10
|
||||
std::string copy{str_with_len_N};/23_mean 91.6 ns 91.6 ns 10
|
||||
std::string copy{str_with_len_N};/23_median 91.7 ns 91.7 ns 10
|
||||
std::string copy{str_with_len_N};/23_stddev 3.83 ns 3.83 ns 10
|
||||
std::string copy{str_with_len_N};/23_cv 4.18 % 4.18 % 10
|
||||
std::string copy{str_with_len_N};/24_mean 94.5 ns 94.5 ns 10
|
||||
std::string copy{str_with_len_N};/24_median 94.9 ns 94.9 ns 10
|
||||
std::string copy{str_with_len_N};/24_stddev 3.26 ns 3.26 ns 10
|
||||
std::string copy{str_with_len_N};/24_cv 3.45 % 3.45 % 10
|
||||
std::string copy{str_with_len_N};/32_mean 97.0 ns 97.0 ns 10
|
||||
std::string copy{str_with_len_N};/32_median 97.4 ns 97.4 ns 10
|
||||
std::string copy{str_with_len_N};/32_stddev 3.12 ns 3.12 ns 10
|
||||
std::string copy{str_with_len_N};/32_cv 3.22 % 3.22 % 10
|
||||
std::string copy{str_with_len_N};/64_mean 98.1 ns 98.1 ns 10
|
||||
std::string copy{str_with_len_N};/64_median 97.6 ns 97.6 ns 10
|
||||
std::string copy{str_with_len_N};/64_stddev 4.22 ns 4.22 ns 10
|
||||
std::string copy{str_with_len_N};/64_cv 4.30 % 4.30 % 10
|
||||
std::string copy{str_with_len_N};/128_mean 103 ns 103 ns 10
|
||||
std::string copy{str_with_len_N};/128_median 100 ns 100 ns 10
|
||||
std::string copy{str_with_len_N};/128_stddev 9.59 ns 9.59 ns 10
|
||||
std::string copy{str_with_len_N};/128_cv 9.29 % 9.29 % 10
|
||||
std::string copy{str_with_len_N};/256_mean 161 ns 161 ns 10
|
||||
std::string copy{str_with_len_N};/256_median 180 ns 180 ns 10
|
||||
std::string copy{str_with_len_N};/256_stddev 40.6 ns 40.6 ns 10
|
||||
std::string copy{str_with_len_N};/256_cv 25.29 % 25.29 % 10
|
||||
std::string copy{str_with_len_N};/512_mean 151 ns 151 ns 10
|
||||
std::string copy{str_with_len_N};/512_median 150 ns 150 ns 10
|
||||
std::string copy{str_with_len_N};/512_stddev 38.1 ns 38.1 ns 10
|
||||
std::string copy{str_with_len_N};/512_cv 25.27 % 25.27 % 10
|
||||
std::string copy{str_with_len_N};/1024_mean 131 ns 131 ns 10
|
||||
std::string copy{str_with_len_N};/1024_median 126 ns 126 ns 10
|
||||
std::string copy{str_with_len_N};/1024_stddev 21.4 ns 21.4 ns 10
|
||||
std::string copy{str_with_len_N};/1024_cv 16.31 % 16.31 % 10
|
||||
std::string copy{str_with_len_N};/2048_mean 148 ns 148 ns 10
|
||||
std::string copy{str_with_len_N};/2048_median 145 ns 145 ns 10
|
||||
std::string copy{str_with_len_N};/2048_stddev 10.5 ns 10.5 ns 10
|
||||
std::string copy{str_with_len_N};/2048_cv 7.09 % 7.09 % 10
|
||||
std::string copy{str_with_len_N};/4096_mean 185 ns 185 ns 10
|
||||
std::string copy{str_with_len_N};/4096_median 183 ns 183 ns 10
|
||||
std::string copy{str_with_len_N};/4096_stddev 8.27 ns 8.27 ns 10
|
||||
std::string copy{str_with_len_N};/4096_cv 4.47 % 4.47 % 10
|
||||
stringa copy{str_with_len_N};/15_mean 5.19 ns 5.19 ns 10
|
||||
stringa copy{str_with_len_N};/15_median 5.13 ns 5.13 ns 10
|
||||
stringa copy{str_with_len_N};/15_stddev 0.223 ns 0.223 ns 10
|
||||
stringa copy{str_with_len_N};/15_cv 4.29 % 4.29 % 10
|
||||
stringa copy{str_with_len_N};/16_mean 10.0 ns 10.0 ns 10
|
||||
stringa copy{str_with_len_N};/16_median 9.95 ns 9.95 ns 10
|
||||
stringa copy{str_with_len_N};/16_stddev 0.218 ns 0.218 ns 10
|
||||
stringa copy{str_with_len_N};/16_cv 2.17 % 2.17 % 10
|
||||
stringa copy{str_with_len_N};/23_mean 9.97 ns 9.97 ns 10
|
||||
stringa copy{str_with_len_N};/23_median 9.91 ns 9.91 ns 10
|
||||
stringa copy{str_with_len_N};/23_stddev 0.223 ns 0.223 ns 10
|
||||
stringa copy{str_with_len_N};/23_cv 2.23 % 2.23 % 10
|
||||
stringa copy{str_with_len_N};/24_mean 10.1 ns 10.1 ns 10
|
||||
stringa copy{str_with_len_N};/24_median 9.98 ns 9.98 ns 10
|
||||
stringa copy{str_with_len_N};/24_stddev 0.238 ns 0.238 ns 10
|
||||
stringa copy{str_with_len_N};/24_cv 2.36 % 2.36 % 10
|
||||
stringa copy{str_with_len_N};/32_mean 10.0 ns 10.0 ns 10
|
||||
stringa copy{str_with_len_N};/32_median 10.0 ns 10.0 ns 10
|
||||
stringa copy{str_with_len_N};/32_stddev 0.122 ns 0.122 ns 10
|
||||
stringa copy{str_with_len_N};/32_cv 1.21 % 1.21 % 10
|
||||
stringa copy{str_with_len_N};/64_mean 9.95 ns 9.95 ns 10
|
||||
stringa copy{str_with_len_N};/64_median 9.90 ns 9.90 ns 10
|
||||
stringa copy{str_with_len_N};/64_stddev 0.145 ns 0.145 ns 10
|
||||
stringa copy{str_with_len_N};/64_cv 1.46 % 1.46 % 10
|
||||
stringa copy{str_with_len_N};/128_mean 9.93 ns 9.93 ns 10
|
||||
stringa copy{str_with_len_N};/128_median 9.90 ns 9.90 ns 10
|
||||
stringa copy{str_with_len_N};/128_stddev 0.178 ns 0.178 ns 10
|
||||
stringa copy{str_with_len_N};/128_cv 1.79 % 1.79 % 10
|
||||
stringa copy{str_with_len_N};/256_mean 9.95 ns 9.95 ns 10
|
||||
stringa copy{str_with_len_N};/256_median 9.92 ns 9.92 ns 10
|
||||
stringa copy{str_with_len_N};/256_stddev 0.112 ns 0.112 ns 10
|
||||
stringa copy{str_with_len_N};/256_cv 1.13 % 1.13 % 10
|
||||
stringa copy{str_with_len_N};/512_mean 10.0 ns 10.0 ns 10
|
||||
stringa copy{str_with_len_N};/512_median 9.94 ns 9.94 ns 10
|
||||
stringa copy{str_with_len_N};/512_stddev 0.214 ns 0.214 ns 10
|
||||
stringa copy{str_with_len_N};/512_cv 2.13 % 2.13 % 10
|
||||
stringa copy{str_with_len_N};/1024_mean 9.92 ns 9.92 ns 10
|
||||
stringa copy{str_with_len_N};/1024_median 9.90 ns 9.90 ns 10
|
||||
stringa copy{str_with_len_N};/1024_stddev 0.113 ns 0.113 ns 10
|
||||
stringa copy{str_with_len_N};/1024_cv 1.14 % 1.14 % 10
|
||||
stringa copy{str_with_len_N};/2048_mean 10.0 ns 10.0 ns 10
|
||||
stringa copy{str_with_len_N};/2048_median 9.97 ns 9.97 ns 10
|
||||
stringa copy{str_with_len_N};/2048_stddev 0.174 ns 0.174 ns 10
|
||||
stringa copy{str_with_len_N};/2048_cv 1.73 % 1.73 % 10
|
||||
stringa copy{str_with_len_N};/4096_mean 10.1 ns 10.1 ns 10
|
||||
stringa copy{str_with_len_N};/4096_median 9.99 ns 9.99 ns 10
|
||||
stringa copy{str_with_len_N};/4096_stddev 0.212 ns 0.212 ns 10
|
||||
stringa copy{str_with_len_N};/4096_cv 2.11 % 2.11 % 10
|
||||
lstringa<16> copy{str_with_len_N};/15_mean 17.2 ns 17.2 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_median 17.0 ns 17.0 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_stddev 1.43 ns 1.43 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_cv 8.29 % 8.29 % 10
|
||||
lstringa<16> copy{str_with_len_N};/16_mean 17.0 ns 17.0 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_median 17.0 ns 17.0 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_stddev 0.735 ns 0.735 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_cv 4.33 % 4.33 % 10
|
||||
lstringa<16> copy{str_with_len_N};/23_mean 77.8 ns 77.8 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_median 77.4 ns 77.4 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_stddev 2.84 ns 2.84 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_cv 3.65 % 3.65 % 10
|
||||
lstringa<16> copy{str_with_len_N};/24_mean 76.5 ns 76.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_median 76.1 ns 76.1 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_stddev 1.45 ns 1.45 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_cv 1.90 % 1.90 % 10
|
||||
lstringa<16> copy{str_with_len_N};/32_mean 79.5 ns 79.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_median 80.2 ns 80.2 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_stddev 3.63 ns 3.63 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_cv 4.57 % 4.57 % 10
|
||||
lstringa<16> copy{str_with_len_N};/64_mean 82.9 ns 82.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_median 81.8 ns 81.8 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_stddev 7.03 ns 7.03 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_cv 8.48 % 8.48 % 10
|
||||
lstringa<16> copy{str_with_len_N};/128_mean 83.0 ns 83.0 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_median 82.3 ns 82.3 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_stddev 5.89 ns 5.89 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_cv 7.10 % 7.10 % 10
|
||||
lstringa<16> copy{str_with_len_N};/256_mean 133 ns 133 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_median 152 ns 152 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_stddev 34.9 ns 34.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_cv 26.21 % 26.21 % 10
|
||||
lstringa<16> copy{str_with_len_N};/512_mean 130 ns 130 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_median 131 ns 131 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_stddev 38.4 ns 38.4 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_cv 29.57 % 29.57 % 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_mean 111 ns 111 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_median 102 ns 102 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_stddev 19.9 ns 19.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_cv 17.84 % 17.84 % 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_mean 122 ns 122 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_median 122 ns 122 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_stddev 4.77 ns 4.77 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_cv 3.91 % 3.91 % 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_mean 167 ns 167 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_median 167 ns 167 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_stddev 2.97 ns 2.97 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_cv 1.77 % 1.77 % 10
|
||||
lstringa<512> copy{str_with_len_N};/15_mean 17.9 ns 17.9 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_median 17.8 ns 17.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_stddev 0.742 ns 0.742 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_cv 4.16 % 4.16 % 10
|
||||
lstringa<512> copy{str_with_len_N};/16_mean 18.5 ns 18.5 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_median 18.3 ns 18.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_stddev 1.16 ns 1.16 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_cv 6.28 % 6.28 % 10
|
||||
lstringa<512> copy{str_with_len_N};/23_mean 18.6 ns 18.6 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_median 18.4 ns 18.4 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_stddev 0.848 ns 0.848 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_cv 4.56 % 4.56 % 10
|
||||
lstringa<512> copy{str_with_len_N};/24_mean 18.8 ns 18.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_median 18.6 ns 18.6 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_stddev 0.881 ns 0.881 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_cv 4.68 % 4.68 % 10
|
||||
lstringa<512> copy{str_with_len_N};/32_mean 25.0 ns 25.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_median 24.3 ns 24.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_stddev 1.68 ns 1.68 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_cv 6.71 % 6.71 % 10
|
||||
lstringa<512> copy{str_with_len_N};/64_mean 21.2 ns 21.2 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_median 21.0 ns 21.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_stddev 0.789 ns 0.789 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_cv 3.72 % 3.72 % 10
|
||||
lstringa<512> copy{str_with_len_N};/128_mean 22.3 ns 22.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_median 22.2 ns 22.2 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_stddev 0.675 ns 0.675 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_cv 3.02 % 3.02 % 10
|
||||
lstringa<512> copy{str_with_len_N};/256_mean 24.0 ns 24.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_median 23.9 ns 23.9 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_stddev 0.383 ns 0.383 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_cv 1.60 % 1.60 % 10
|
||||
lstringa<512> copy{str_with_len_N};/512_mean 26.8 ns 26.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_median 26.7 ns 26.7 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_stddev 0.830 ns 0.830 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_cv 3.09 % 3.09 % 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_mean 113 ns 113 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_median 106 ns 106 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_stddev 26.0 ns 26.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_cv 23.08 % 23.08 % 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_mean 129 ns 129 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_median 129 ns 129 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_stddev 5.50 ns 5.50 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_cv 4.26 % 4.26 % 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_mean 169 ns 169 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_median 167 ns 167 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_stddev 5.95 ns 5.95 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_cv 3.51 % 3.51 % 10
|
||||
----- Convert to int '1234567' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_mean 204 ns 204 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_median 203 ns 203 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_stddev 10.00 ns 10.00 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_cv 4.89 % 4.89 % 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_mean 65.9 ns 65.9 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_median 65.8 ns 65.8 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_stddev 0.675 ns 0.675 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_cv 1.02 % 1.02 % 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 58.9 ns 58.9 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_median 57.5 ns 57.5 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 3.92 ns 3.92 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 6.65 % 6.65 % 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 54.2 ns 54.2 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_median 54.0 ns 54.0 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 2.00 ns 2.00 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 3.69 % 3.69 % 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 54.1 ns 54.1 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_median 53.9 ns 53.9 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 1.31 ns 1.31 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 2.42 % 2.42 % 10
|
||||
----- Convert to unsigned 'abcDef' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_mean 158 ns 158 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_median 154 ns 154 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_stddev 7.54 ns 7.54 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_cv 4.78 % 4.78 % 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_mean 85.4 ns 85.4 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_median 85.3 ns 85.3 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_stddev 1.31 ns 1.31 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_cv 1.53 % 1.53 % 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 50.4 ns 50.4 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 50.7 ns 50.7 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 1.67 ns 1.67 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 3.32 % 3.32 % 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 47.5 ns 47.5 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 47.3 ns 47.3 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 1.31 ns 1.31 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 2.76 % 2.76 % 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 47.2 ns 47.2 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 46.5 ns 46.5 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 2.98 ns 2.98 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 6.32 % 6.32 % 10
|
||||
----- Convert to int ' 1234567' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_mean 226 ns 226 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_median 225 ns 225 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_stddev 13.9 ns 13.9 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_cv 6.15 % 6.15 % 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_mean 80.3 ns 80.3 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_median 79.8 ns 79.8 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_stddev 2.73 ns 2.73 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_cv 3.40 % 3.40 % 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_mean 53.0 ns 53.0 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_median 52.8 ns 52.8 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_stddev 0.840 ns 0.840 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_cv 1.58 % 1.58 % 10
|
||||
----- Convert to double '1234.567e10' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_mean 460 ns 460 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_median 454 ns 454 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_stddev 19.7 ns 19.7 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_cv 4.28 % 4.28 % 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_mean 294 ns 294 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_median 291 ns 291 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_stddev 6.63 ns 6.63 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_cv 2.26 % 2.26 % 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_mean 105 ns 105 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_median 103 ns 103 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_stddev 6.39 ns 6.38 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_cv 6.06 % 6.06 % 10
|
||||
-- Append const literal of 16 bytes 64 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_mean 11819 ns 11819 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_median 11691 ns 11691 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_stddev 494 ns 494 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_cv 4.18 % 4.18 % 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_mean 1174 ns 1174 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_median 1168 ns 1168 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_stddev 76.0 ns 76.0 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_cv 6.48 % 6.47 % 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_mean 1294 ns 1294 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_median 1287 ns 1287 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_stddev 68.2 ns 68.2 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_cv 5.27 % 5.27 % 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_mean 900 ns 900 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_median 912 ns 912 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_stddev 52.1 ns 52.1 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_cv 5.79 % 5.79 % 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_mean 637 ns 637 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_median 631 ns 631 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_stddev 44.2 ns 44.2 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_cv 6.94 % 6.94 % 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_mean 501 ns 501 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_median 497 ns 497 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_stddev 11.0 ns 11.0 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_cv 2.20 % 2.20 % 10
|
||||
-- Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_mean 11807 ns 11807 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_median 11726 ns 11726 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_stddev 449 ns 449 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_cv 3.80 % 3.80 % 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_mean 4085 ns 4085 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_median 4020 ns 4020 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_stddev 196 ns 196 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_cv 4.81 % 4.81 % 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_mean 1439 ns 1439 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_median 1449 ns 1449 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_stddev 74.9 ns 74.9 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_cv 5.20 % 5.20 % 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_mean 1179 ns 1179 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_median 1186 ns 1186 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_stddev 98.7 ns 98.7 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_cv 8.37 % 8.37 % 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_mean 934 ns 934 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_median 924 ns 924 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_stddev 80.9 ns 80.9 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_cv 8.67 % 8.67 % 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_mean 734 ns 734 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_median 727 ns 727 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_stddev 22.0 ns 22.0 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_cv 3.00 % 3.00 % 10
|
||||
-- Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_mean 609176 ns 609186 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_median 604318 ns 604351 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_stddev 23440 ns 23440 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_cv 3.85 % 3.85 % 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 207760 ns 207762 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 210493 ns 210494 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 8896 ns 8897 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 4.28 % 4.28 % 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 53812 ns 53812 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 53544 ns 53544 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 2281 ns 2281 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 4.24 % 4.24 % 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 51889 ns 51889 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 51942 ns 51942 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 1660 ns 1660 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 3.20 % 3.20 % 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 50113 ns 50114 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 50056 ns 50057 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 811 ns 811 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 1.62 % 1.62 % 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 52780 ns 52781 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 51519 ns 51519 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 2889 ns 2889 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 5.47 % 5.47 % 10
|
||||
-- Append 2 string of 16 bytes 32 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_mean 11836 ns 11836 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_median 11842 ns 11842 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_stddev 396 ns 396 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_cv 3.35 % 3.35 % 10
|
||||
std::string str; ... str += str_var1 + str_var2;_mean 4507 ns 4507 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_median 4543 ns 4543 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_stddev 123 ns 123 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_cv 2.73 % 2.73 % 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_mean 1657 ns 1657 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_median 1646 ns 1646 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_stddev 80.2 ns 80.2 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_cv 4.84 % 4.84 % 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_mean 1413 ns 1413 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_median 1392 ns 1392 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_stddev 97.3 ns 97.3 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_cv 6.89 % 6.89 % 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_mean 1088 ns 1088 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_median 1065 ns 1065 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_stddev 58.8 ns 58.8 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_cv 5.40 % 5.40 % 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_mean 977 ns 977 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_median 979 ns 979 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_stddev 45.7 ns 45.7 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_cv 4.68 % 4.68 % 10
|
||||
-- Append text, number, text --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; str << "test = " << k << " times";_mean 19450 ns 19450 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_median 19297 ns 19297 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_stddev 1456 ns 1456 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_cv 7.49 % 7.49 % 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_mean 3261 ns 3261 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_median 3216 ns 3216 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_stddev 181 ns 181 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_cv 5.55 % 5.55 % 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_mean 7677 ns 7677 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_median 7790 ns 7791 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_stddev 383 ns 383 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_cv 4.99 % 4.99 % 10
|
||||
std::string str = std::format("test = {} times", k);_mean 4200 ns 4200 ns 10
|
||||
std::string str = std::format("test = {} times", k);_median 4204 ns 4204 ns 10
|
||||
std::string str = std::format("test = {} times", k);_stddev 136 ns 136 ns 10
|
||||
std::string str = std::format("test = {} times", k);_cv 3.24 % 3.24 % 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_mean 6598 ns 6598 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_median 6515 ns 6515 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_stddev 407 ns 407 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_cv 6.17 % 6.17 % 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_mean 4632 ns 4632 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_median 4696 ns 4696 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_stddev 149 ns 149 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_cv 3.22 % 3.22 % 10
|
||||
lstringa<8> str = "test = " + k + " times";_mean 1342 ns 1342 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_median 1347 ns 1347 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_stddev 41.9 ns 41.9 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_cv 3.13 % 3.13 % 10
|
||||
lstringa<32> str = "test = " + k + " times";_mean 614 ns 614 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_median 603 ns 603 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_stddev 35.5 ns 35.5 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_cv 5.78 % 5.78 % 10
|
||||
stringa str = "test = " + k + " times";_mean 1303 ns 1303 ns 10
|
||||
stringa str = "test = " + k + " times";_median 1307 ns 1307 ns 10
|
||||
stringa str = "test = " + k + " times";_stddev 58.0 ns 58.0 ns 10
|
||||
stringa str = "test = " + k + " times";_cv 4.45 % 4.45 % 10
|
||||
-- Split text and convert to int --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string::find + substr + std::strtol_mean 1414 ns 1414 ns 10
|
||||
std::string::find + substr + std::strtol_median 1408 ns 1408 ns 10
|
||||
std::string::find + substr + std::strtol_stddev 67.5 ns 67.5 ns 10
|
||||
std::string::find + substr + std::strtol_cv 4.78 % 4.78 % 10
|
||||
ssa::splitter + ssa::as_int_mean 670 ns 670 ns 10
|
||||
ssa::splitter + ssa::as_int_median 654 ns 654 ns 10
|
||||
ssa::splitter + ssa::as_int_stddev 34.0 ns 34.0 ns 10
|
||||
ssa::splitter + ssa::as_int_cv 5.07 % 5.07 % 10
|
||||
ssa::splitf + functor_mean 939 ns 939 ns 10
|
||||
ssa::splitf + functor_median 927 ns 927 ns 10
|
||||
ssa::splitf + functor_stddev 32.8 ns 32.8 ns 10
|
||||
ssa::splitf + functor_cv 3.49 % 3.49 % 10
|
||||
-- Replace symbols in text ~400 symbols --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Naive (and wrong) replace symbols with std::string find + replace_mean 6175 ns 6175 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_median 6116 ns 6116 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_stddev 236 ns 236 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_cv 3.82 % 3.82 % 10
|
||||
replace symbols with std::string find_first_of + replace_mean 10124 ns 10125 ns 10
|
||||
replace symbols with std::string find_first_of + replace_median 10071 ns 10071 ns 10
|
||||
replace symbols with std::string find_first_of + replace_stddev 222 ns 222 ns 10
|
||||
replace symbols with std::string find_first_of + replace_cv 2.20 % 2.20 % 10
|
||||
replace symbols with std::string_view find_first_of + copy_mean 5505 ns 5505 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_median 5527 ns 5527 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_stddev 215 ns 215 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_cv 3.91 % 3.91 % 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_mean 5599 ns 5599 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_median 5526 ns 5526 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_stddev 255 ns 255 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_cv 4.56 % 4.56 % 10
|
||||
replace runtime symbols with simstr and memorization of all search results_mean 5123 ns 5123 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_median 5130 ns 5130 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_stddev 196 ns 196 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_cv 3.83 % 3.83 % 10
|
||||
replace const symbols with string expressions and without remembering all search results_mean 4773 ns 4773 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_median 4789 ns 4789 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_stddev 152 ns 152 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_cv 3.18 % 3.18 % 10
|
||||
replace const symbols with string expressions and memorization of all search results_mean 4477 ns 4477 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_median 4417 ns 4417 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_stddev 232 ns 232 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_cv 5.18 % 5.18 % 10
|
||||
-- Replace symbols in text ~40 symbols --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_mean 827 ns 827 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_median 805 ns 805 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_stddev 55.5 ns 55.5 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_cv 6.71 % 6.71 % 10
|
||||
Short replace symbols with std::string find_first_of + replace_mean 1187 ns 1187 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_median 1191 ns 1192 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_stddev 22.7 ns 22.7 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_cv 1.92 % 1.92 % 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_mean 694 ns 694 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_median 695 ns 695 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_stddev 35.3 ns 35.3 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_cv 5.09 % 5.09 % 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_mean 583 ns 583 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_median 580 ns 580 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_stddev 14.7 ns 14.7 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_cv 2.52 % 2.52 % 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_mean 669 ns 669 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_median 653 ns 653 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_stddev 41.6 ns 41.6 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_cv 6.22 % 6.22 % 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_mean 440 ns 440 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_median 434 ns 434 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_stddev 21.5 ns 21.5 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_cv 4.89 % 4.89 % 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_mean 512 ns 512 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_median 497 ns 497 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_stddev 42.4 ns 42.4 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_cv 8.29 % 8.29 % 10
|
||||
----- Replace All Str To Longer Size ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
replace bb to ---- in std::string|64_mean 759 ns 759 ns 10
|
||||
replace bb to ---- in std::string|64_median 756 ns 756 ns 10
|
||||
replace bb to ---- in std::string|64_stddev 35.6 ns 35.6 ns 10
|
||||
replace bb to ---- in std::string|64_cv 4.69 % 4.69 % 10
|
||||
replace bb to ---- in std::string|256_mean 2371 ns 2371 ns 10
|
||||
replace bb to ---- in std::string|256_median 2356 ns 2356 ns 10
|
||||
replace bb to ---- in std::string|256_stddev 141 ns 141 ns 10
|
||||
replace bb to ---- in std::string|256_cv 5.97 % 5.97 % 10
|
||||
replace bb to ---- in std::string|512_mean 4397 ns 4397 ns 10
|
||||
replace bb to ---- in std::string|512_median 4347 ns 4347 ns 10
|
||||
replace bb to ---- in std::string|512_stddev 209 ns 209 ns 10
|
||||
replace bb to ---- in std::string|512_cv 4.75 % 4.75 % 10
|
||||
replace bb to ---- in std::string|1024_mean 8983 ns 8983 ns 10
|
||||
replace bb to ---- in std::string|1024_median 8903 ns 8903 ns 10
|
||||
replace bb to ---- in std::string|1024_stddev 716 ns 716 ns 10
|
||||
replace bb to ---- in std::string|1024_cv 7.97 % 7.97 % 10
|
||||
replace bb to ---- in std::string|2048_mean 20059 ns 20059 ns 10
|
||||
replace bb to ---- in std::string|2048_median 20184 ns 20184 ns 10
|
||||
replace bb to ---- in std::string|2048_stddev 599 ns 599 ns 10
|
||||
replace bb to ---- in std::string|2048_cv 2.99 % 2.99 % 10
|
||||
replace bb to ---- in lstringa<8>|64_mean 734 ns 734 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_median 729 ns 729 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_stddev 12.3 ns 12.3 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_cv 1.67 % 1.67 % 10
|
||||
replace bb to ---- in lstringa<8>|256_mean 2096 ns 2096 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_median 2094 ns 2094 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_stddev 98.1 ns 98.1 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_cv 4.68 % 4.68 % 10
|
||||
replace bb to ---- in lstringa<8>|512_mean 3770 ns 3770 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_median 3744 ns 3744 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_stddev 171 ns 171 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_cv 4.53 % 4.53 % 10
|
||||
replace bb to ---- in lstringa<8>|1024_mean 7288 ns 7288 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_median 7121 ns 7121 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_stddev 470 ns 470 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_cv 6.45 % 6.45 % 10
|
||||
replace bb to ---- in lstringa<8>|2048_mean 13342 ns 13342 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_median 13306 ns 13306 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_stddev 401 ns 401 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_cv 3.01 % 3.01 % 10
|
||||
replace bb to ---- by init stringa|64_mean 498 ns 498 ns 10
|
||||
replace bb to ---- by init stringa|64_median 490 ns 490 ns 10
|
||||
replace bb to ---- by init stringa|64_stddev 42.1 ns 42.1 ns 10
|
||||
replace bb to ---- by init stringa|64_cv 8.46 % 8.46 % 10
|
||||
replace bb to ---- by init stringa|256_mean 1896 ns 1896 ns 10
|
||||
replace bb to ---- by init stringa|256_median 1905 ns 1905 ns 10
|
||||
replace bb to ---- by init stringa|256_stddev 42.1 ns 42.1 ns 10
|
||||
replace bb to ---- by init stringa|256_cv 2.22 % 2.22 % 10
|
||||
replace bb to ---- by init stringa|512_mean 3611 ns 3611 ns 10
|
||||
replace bb to ---- by init stringa|512_median 3605 ns 3605 ns 10
|
||||
replace bb to ---- by init stringa|512_stddev 99.0 ns 99.0 ns 10
|
||||
replace bb to ---- by init stringa|512_cv 2.74 % 2.74 % 10
|
||||
replace bb to ---- by init stringa|1024_mean 6933 ns 6933 ns 10
|
||||
replace bb to ---- by init stringa|1024_median 6974 ns 6974 ns 10
|
||||
replace bb to ---- by init stringa|1024_stddev 208 ns 208 ns 10
|
||||
replace bb to ---- by init stringa|1024_cv 3.00 % 3.00 % 10
|
||||
replace bb to ---- by init stringa|2048_mean 13812 ns 13812 ns 10
|
||||
replace bb to ---- by init stringa|2048_median 13831 ns 13831 ns 10
|
||||
replace bb to ---- by init stringa|2048_stddev 412 ns 412 ns 10
|
||||
replace bb to ---- by init stringa|2048_cv 2.98 % 2.98 % 10
|
||||
----- Replace All Str To Same Size ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
replace bb to -- in std::string|64_mean 545 ns 545 ns 10
|
||||
replace bb to -- in std::string|64_median 546 ns 546 ns 10
|
||||
replace bb to -- in std::string|64_stddev 13.4 ns 13.4 ns 10
|
||||
replace bb to -- in std::string|64_cv 2.45 % 2.45 % 10
|
||||
replace bb to -- in std::string|256_mean 1885 ns 1885 ns 10
|
||||
replace bb to -- in std::string|256_median 1853 ns 1853 ns 10
|
||||
replace bb to -- in std::string|256_stddev 113 ns 113 ns 10
|
||||
replace bb to -- in std::string|256_cv 6.00 % 6.00 % 10
|
||||
replace bb to -- in std::string|512_mean 3368 ns 3368 ns 10
|
||||
replace bb to -- in std::string|512_median 3358 ns 3358 ns 10
|
||||
replace bb to -- in std::string|512_stddev 107 ns 107 ns 10
|
||||
replace bb to -- in std::string|512_cv 3.17 % 3.17 % 10
|
||||
replace bb to -- in std::string|1024_mean 6925 ns 6925 ns 10
|
||||
replace bb to -- in std::string|1024_median 6910 ns 6910 ns 10
|
||||
replace bb to -- in std::string|1024_stddev 344 ns 344 ns 10
|
||||
replace bb to -- in std::string|1024_cv 4.97 % 4.97 % 10
|
||||
replace bb to -- in std::string|2048_mean 13051 ns 13051 ns 10
|
||||
replace bb to -- in std::string|2048_median 12940 ns 12940 ns 10
|
||||
replace bb to -- in std::string|2048_stddev 417 ns 417 ns 10
|
||||
replace bb to -- in std::string|2048_cv 3.19 % 3.19 % 10
|
||||
replace bb to -- in lstringa<8>|64_mean 483 ns 483 ns 10
|
||||
replace bb to -- in lstringa<8>|64_median 477 ns 477 ns 10
|
||||
replace bb to -- in lstringa<8>|64_stddev 28.3 ns 28.3 ns 10
|
||||
replace bb to -- in lstringa<8>|64_cv 5.85 % 5.85 % 10
|
||||
replace bb to -- in lstringa<8>|256_mean 1542 ns 1542 ns 10
|
||||
replace bb to -- in lstringa<8>|256_median 1531 ns 1531 ns 10
|
||||
replace bb to -- in lstringa<8>|256_stddev 78.0 ns 78.0 ns 10
|
||||
replace bb to -- in lstringa<8>|256_cv 5.06 % 5.06 % 10
|
||||
replace bb to -- in lstringa<8>|512_mean 2827 ns 2827 ns 10
|
||||
replace bb to -- in lstringa<8>|512_median 2815 ns 2815 ns 10
|
||||
replace bb to -- in lstringa<8>|512_stddev 123 ns 123 ns 10
|
||||
replace bb to -- in lstringa<8>|512_cv 4.34 % 4.34 % 10
|
||||
replace bb to -- in lstringa<8>|1024_mean 5568 ns 5568 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_median 5501 ns 5501 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_stddev 387 ns 387 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_cv 6.95 % 6.95 % 10
|
||||
replace bb to -- in lstringa<8>|2048_mean 10863 ns 10863 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_median 10863 ns 10863 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_stddev 541 ns 541 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_cv 4.98 % 4.98 % 10
|
||||
replace bb to -- by init stringa|64_mean 363 ns 363 ns 10
|
||||
replace bb to -- by init stringa|64_median 356 ns 356 ns 10
|
||||
replace bb to -- by init stringa|64_stddev 23.8 ns 23.8 ns 10
|
||||
replace bb to -- by init stringa|64_cv 6.57 % 6.56 % 10
|
||||
replace bb to -- by init stringa|256_mean 1249 ns 1249 ns 10
|
||||
replace bb to -- by init stringa|256_median 1176 ns 1176 ns 10
|
||||
replace bb to -- by init stringa|256_stddev 145 ns 145 ns 10
|
||||
replace bb to -- by init stringa|256_cv 11.61 % 11.61 % 10
|
||||
replace bb to -- by init stringa|512_mean 2243 ns 2243 ns 10
|
||||
replace bb to -- by init stringa|512_median 2206 ns 2206 ns 10
|
||||
replace bb to -- by init stringa|512_stddev 131 ns 131 ns 10
|
||||
replace bb to -- by init stringa|512_cv 5.85 % 5.85 % 10
|
||||
replace bb to -- by init stringa|1024_mean 4204 ns 4204 ns 10
|
||||
replace bb to -- by init stringa|1024_median 4185 ns 4185 ns 10
|
||||
replace bb to -- by init stringa|1024_stddev 123 ns 123 ns 10
|
||||
replace bb to -- by init stringa|1024_cv 2.92 % 2.92 % 10
|
||||
replace bb to -- by init stringa|2048_mean 8206 ns 8207 ns 10
|
||||
replace bb to -- by init stringa|2048_median 8270 ns 8270 ns 10
|
||||
replace bb to -- by init stringa|2048_stddev 171 ns 171 ns 10
|
||||
replace bb to -- by init stringa|2048_cv 2.09 % 2.09 % 10
|
||||
----- Hash Map insert and find ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
hashStrMapA<size_t> emplace & find stringa;_mean 5371717 ns 5371764 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_median 5351902 ns 5351957 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_stddev 95139 ns 95136 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_cv 1.77 % 1.77 % 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_mean 5883527 ns 5883602 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_median 5863441 ns 5863495 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_stddev 121360 ns 121344 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_cv 2.06 % 2.06 % 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_mean 5376097 ns 5376160 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_median 5396723 ns 5396748 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_stddev 55934 ns 55933 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_cv 1.04 % 1.04 % 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_mean 6884220 ns 6884269 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_median 6758571 ns 6758571 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_stddev 494224 ns 494235 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_cv 7.18 % 7.18 % 10
|
||||
----- Build Full Func Name ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Build func full name std::string;_mean 4861 ns 4861 ns 10
|
||||
Build func full name std::string;_median 4830 ns 4830 ns 10
|
||||
Build func full name std::string;_stddev 214 ns 214 ns 10
|
||||
Build func full name std::string;_cv 4.41 % 4.41 % 10
|
||||
Build func full name std::string 1;_mean 5220 ns 5220 ns 10
|
||||
Build func full name std::string 1;_median 5168 ns 5168 ns 10
|
||||
Build func full name std::string 1;_stddev 379 ns 379 ns 10
|
||||
Build func full name std::string 1;_cv 7.27 % 7.27 % 10
|
||||
Build func full name std::stream;_mean 16474 ns 16474 ns 10
|
||||
Build func full name std::stream;_median 16253 ns 16253 ns 10
|
||||
Build func full name std::stream;_stddev 1049 ns 1049 ns 10
|
||||
Build func full name std::stream;_cv 6.37 % 6.37 % 10
|
||||
Build func full name stringa;_mean 2853 ns 2853 ns 10
|
||||
Build func full name stringa;_median 2857 ns 2857 ns 10
|
||||
Build func full name stringa;_stddev 63.2 ns 63.2 ns 10
|
||||
Build func full name stringa;_cv 2.22 % 2.22 % 10
|
||||
Build func full name stringa 1;_mean 3292 ns 3292 ns 10
|
||||
Build func full name stringa 1;_median 3292 ns 3292 ns 10
|
||||
Build func full name stringa 1;_stddev 91.3 ns 91.3 ns 10
|
||||
Build func full name stringa 1;_cv 2.77 % 2.77 % 10
|
||||
|
|
@ -0,0 +1,870 @@
|
|||
Run on (32 X 2513.96 MHz CPU s)
|
||||
Firefox: 146.0.1.60 webasm
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Benchmark Time CPU Iterations
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
----- Concatenate string + Number + "Literal" ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Concat std::string and number by std to std::string_mean 925 ns 925 ns 10
|
||||
Concat std::string and number by std to std::string_median 933 ns 933 ns 10
|
||||
Concat std::string and number by std to std::string_stddev 46.4 ns 46.4 ns 10
|
||||
Concat std::string and number by std to std::string_cv 5.01 % 5.01 % 10
|
||||
Concat std::string and number by StrExpr to std::string_mean 415 ns 415 ns 10
|
||||
Concat std::string and number by StrExpr to std::string_median 418 ns 418 ns 10
|
||||
Concat std::string and number by StrExpr to std::string_stddev 14.1 ns 14.1 ns 10
|
||||
Concat std::string and number by StrExpr to std::string_cv 3.39 % 3.39 % 10
|
||||
Concat stringa and number by StrExpr to simstr::stringa_mean 211 ns 211 ns 10
|
||||
Concat stringa and number by StrExpr to simstr::stringa_median 213 ns 213 ns 10
|
||||
Concat stringa and number by StrExpr to simstr::stringa_stddev 11.8 ns 11.8 ns 10
|
||||
Concat stringa and number by StrExpr to simstr::stringa_cv 5.56 % 5.56 % 10
|
||||
----- Concatenate string + Hex Number + "Literal" ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Concat std::string and hex number by std to std::string_mean 1446 ns 1446 ns 10
|
||||
Concat std::string and hex number by std to std::string_median 1429 ns 1429 ns 10
|
||||
Concat std::string and hex number by std to std::string_stddev 81.6 ns 81.6 ns 10
|
||||
Concat std::string and hex number by std to std::string_cv 5.64 % 5.64 % 10
|
||||
Concat std::string and hex number by StrExpr to std::string_mean 365 ns 365 ns 10
|
||||
Concat std::string and hex number by StrExpr to std::string_median 367 ns 367 ns 10
|
||||
Concat std::string and hex number by StrExpr to std::string_stddev 17.7 ns 17.7 ns 10
|
||||
Concat std::string and hex number by StrExpr to std::string_cv 4.87 % 4.87 % 10
|
||||
Concat stringa and hex number by StrExpr to simstr::stringa_mean 196 ns 196 ns 10
|
||||
Concat stringa and hex number by StrExpr to simstr::stringa_median 188 ns 188 ns 10
|
||||
Concat stringa and hex number by StrExpr to simstr::stringa_stddev 17.3 ns 17.3 ns 10
|
||||
Concat stringa and hex number by StrExpr to simstr::stringa_cv 8.84 % 8.84 % 10
|
||||
----- Concatenate string + "Literal" ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Concat std::string by std to std::string_mean 111 ns 111 ns 10
|
||||
Concat std::string by std to std::string_median 109 ns 109 ns 10
|
||||
Concat std::string by std to std::string_stddev 4.84 ns 4.84 ns 10
|
||||
Concat std::string by std to std::string_cv 4.37 % 4.37 % 10
|
||||
Concat std::string by StrExpr to std::string_mean 113 ns 113 ns 10
|
||||
Concat std::string by StrExpr to std::string_median 113 ns 113 ns 10
|
||||
Concat std::string by StrExpr to std::string_stddev 5.81 ns 5.80 ns 10
|
||||
Concat std::string by StrExpr to std::string_cv 5.13 % 5.13 % 10
|
||||
Concat stringa by StrExpr to stringa_mean 95.9 ns 95.9 ns 10
|
||||
Concat stringa by StrExpr to stringa_median 95.0 ns 95.0 ns 10
|
||||
Concat stringa by StrExpr to stringa_stddev 6.99 ns 6.99 ns 10
|
||||
Concat stringa by StrExpr to stringa_cv 7.29 % 7.29 % 10
|
||||
----- Find three concatenated string in string_view -----/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Find concat three std::string_mean 178 ns 178 ns 10
|
||||
Find concat three std::string_median 174 ns 174 ns 10
|
||||
Find concat three std::string_stddev 11.0 ns 11.0 ns 10
|
||||
Find concat three std::string_cv 6.19 % 6.19 % 10
|
||||
Find concat three strexpr_mean 106 ns 106 ns 10
|
||||
Find concat three strexpr_median 105 ns 105 ns 10
|
||||
Find concat three strexpr_stddev 3.62 ns 3.62 ns 10
|
||||
Find concat three strexpr_cv 3.42 % 3.43 % 10
|
||||
Find concat three simstr_mean 73.7 ns 73.7 ns 10
|
||||
Find concat three simstr_median 73.7 ns 73.7 ns 10
|
||||
Find concat three simstr_stddev 2.09 ns 2.08 ns 10
|
||||
Find concat three simstr_cv 2.83 % 2.83 % 10
|
||||
----- Build Type Name ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
BuildTypeNameStr 0/0_mean 18.2 ns 18.2 ns 10
|
||||
BuildTypeNameStr 0/0_median 18.5 ns 18.5 ns 10
|
||||
BuildTypeNameStr 0/0_stddev 1.29 ns 1.29 ns 10
|
||||
BuildTypeNameStr 0/0_cv 7.06 % 7.06 % 10
|
||||
BuildTypeNameExp 0/0_mean 17.0 ns 17.0 ns 10
|
||||
BuildTypeNameExp 0/0_median 17.1 ns 17.1 ns 10
|
||||
BuildTypeNameExp 0/0_stddev 0.847 ns 0.847 ns 10
|
||||
BuildTypeNameExp 0/0_cv 4.98 % 4.98 % 10
|
||||
BuildTypeNameSim 0/0_mean 17.0 ns 17.0 ns 10
|
||||
BuildTypeNameSim 0/0_median 16.7 ns 16.7 ns 10
|
||||
BuildTypeNameSim 0/0_stddev 1.17 ns 1.17 ns 10
|
||||
BuildTypeNameSim 0/0_cv 6.90 % 6.90 % 10
|
||||
BuildTypeNameStr 10/10_mean 275 ns 275 ns 10
|
||||
BuildTypeNameStr 10/10_median 276 ns 276 ns 10
|
||||
BuildTypeNameStr 10/10_stddev 13.0 ns 13.0 ns 10
|
||||
BuildTypeNameStr 10/10_cv 4.72 % 4.72 % 10
|
||||
BuildTypeNameExp 10/10_mean 99.6 ns 99.6 ns 10
|
||||
BuildTypeNameExp 10/10_median 101 ns 101 ns 10
|
||||
BuildTypeNameExp 10/10_stddev 6.85 ns 6.85 ns 10
|
||||
BuildTypeNameExp 10/10_cv 6.88 % 6.88 % 10
|
||||
BuildTypeNameSim 10/10_mean 71.2 ns 71.2 ns 10
|
||||
BuildTypeNameSim 10/10_median 69.2 ns 69.2 ns 10
|
||||
BuildTypeNameSim 10/10_stddev 6.72 ns 6.72 ns 10
|
||||
BuildTypeNameSim 10/10_cv 9.44 % 9.44 % 10
|
||||
----- Replace string by copy -----/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Concat with replace str_mean 451 ns 451 ns 10
|
||||
Concat with replace str_median 450 ns 450 ns 10
|
||||
Concat with replace str_stddev 36.0 ns 36.0 ns 10
|
||||
Concat with replace str_cv 7.98 % 7.98 % 10
|
||||
Concat with replace exp_mean 248 ns 248 ns 10
|
||||
Concat with replace exp_median 246 ns 246 ns 10
|
||||
Concat with replace exp_stddev 15.1 ns 15.1 ns 10
|
||||
Concat with replace exp_cv 6.07 % 6.07 % 10
|
||||
----- Create Empty Str ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e;_mean 2.18 ns 2.18 ns 10
|
||||
std::string e;_median 2.18 ns 2.18 ns 10
|
||||
std::string e;_stddev 0.025 ns 0.025 ns 10
|
||||
std::string e;_cv 1.16 % 1.16 % 10
|
||||
std::string_view e;_mean 0.993 ns 0.993 ns 10
|
||||
std::string_view e;_median 0.994 ns 0.994 ns 10
|
||||
std::string_view e;_stddev 0.012 ns 0.012 ns 10
|
||||
std::string_view e;_cv 1.18 % 1.18 % 10
|
||||
ssa e;_mean 0.952 ns 0.952 ns 10
|
||||
ssa e;_median 0.952 ns 0.952 ns 10
|
||||
ssa e;_stddev 0.008 ns 0.008 ns 10
|
||||
ssa e;_cv 0.85 % 0.85 % 10
|
||||
stringa e;_mean 2.19 ns 2.19 ns 10
|
||||
stringa e;_median 2.18 ns 2.18 ns 10
|
||||
stringa e;_stddev 0.048 ns 0.048 ns 10
|
||||
stringa e;_cv 2.19 % 2.19 % 10
|
||||
lstringa<20> e;_mean 2.26 ns 2.26 ns 10
|
||||
lstringa<20> e;_median 2.27 ns 2.27 ns 10
|
||||
lstringa<20> e;_stddev 0.039 ns 0.039 ns 10
|
||||
lstringa<20> e;_cv 1.74 % 1.74 % 10
|
||||
lstringa<40> e;_mean 2.60 ns 2.60 ns 10
|
||||
lstringa<40> e;_median 2.60 ns 2.60 ns 10
|
||||
lstringa<40> e;_stddev 0.032 ns 0.032 ns 10
|
||||
lstringa<40> e;_cv 1.22 % 1.22 % 10
|
||||
----- Create Str from short literal (9 symbols) --------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "Test text";_mean 2.37 ns 2.37 ns 10
|
||||
std::string e = "Test text";_median 2.37 ns 2.37 ns 10
|
||||
std::string e = "Test text";_stddev 0.060 ns 0.060 ns 10
|
||||
std::string e = "Test text";_cv 2.54 % 2.54 % 10
|
||||
std::string_view e = "Test text";_mean 1.29 ns 1.29 ns 10
|
||||
std::string_view e = "Test text";_median 1.27 ns 1.27 ns 10
|
||||
std::string_view e = "Test text";_stddev 0.057 ns 0.057 ns 10
|
||||
std::string_view e = "Test text";_cv 4.41 % 4.41 % 10
|
||||
ssa e = "Test text";_mean 1.01 ns 1.01 ns 10
|
||||
ssa e = "Test text";_median 1.00 ns 1.00 ns 10
|
||||
ssa e = "Test text";_stddev 0.034 ns 0.034 ns 10
|
||||
ssa e = "Test text";_cv 3.32 % 3.32 % 10
|
||||
stringa e = "Test text";_mean 2.63 ns 2.63 ns 10
|
||||
stringa e = "Test text";_median 2.63 ns 2.63 ns 10
|
||||
stringa e = "Test text";_stddev 0.059 ns 0.059 ns 10
|
||||
stringa e = "Test text";_cv 2.24 % 2.24 % 10
|
||||
lstringa<20> e = "Test text";_mean 2.77 ns 2.77 ns 10
|
||||
lstringa<20> e = "Test text";_median 2.77 ns 2.77 ns 10
|
||||
lstringa<20> e = "Test text";_stddev 0.092 ns 0.092 ns 10
|
||||
lstringa<20> e = "Test text";_cv 3.31 % 3.31 % 10
|
||||
lstringa<40> e = "Test text";_mean 2.78 ns 2.78 ns 10
|
||||
lstringa<40> e = "Test text";_median 2.78 ns 2.78 ns 10
|
||||
lstringa<40> e = "Test text";_stddev 0.038 ns 0.038 ns 10
|
||||
lstringa<40> e = "Test text";_cv 1.37 % 1.37 % 10
|
||||
----- Create Str from long literal (30 symbols) ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "123456789012345678901234567890";_mean 16.5 ns 16.5 ns 10
|
||||
std::string e = "123456789012345678901234567890";_median 16.6 ns 16.6 ns 10
|
||||
std::string e = "123456789012345678901234567890";_stddev 0.412 ns 0.412 ns 10
|
||||
std::string e = "123456789012345678901234567890";_cv 2.50 % 2.50 % 10
|
||||
std::string_view e = "123456789012345678901234567890";_mean 1.26 ns 1.26 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_median 1.27 ns 1.27 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_stddev 0.034 ns 0.034 ns 10
|
||||
std::string_view e = "123456789012345678901234567890";_cv 2.66 % 2.66 % 10
|
||||
ssa e = "123456789012345678901234567890";_mean 1.01 ns 1.01 ns 10
|
||||
ssa e = "123456789012345678901234567890";_median 1.01 ns 1.01 ns 10
|
||||
ssa e = "123456789012345678901234567890";_stddev 0.030 ns 0.030 ns 10
|
||||
ssa e = "123456789012345678901234567890";_cv 3.03 % 3.03 % 10
|
||||
stringa e = "123456789012345678901234567890";_mean 2.67 ns 2.67 ns 10
|
||||
stringa e = "123456789012345678901234567890";_median 2.66 ns 2.66 ns 10
|
||||
stringa e = "123456789012345678901234567890";_stddev 0.058 ns 0.058 ns 10
|
||||
stringa e = "123456789012345678901234567890";_cv 2.15 % 2.15 % 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_mean 16.9 ns 16.9 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_median 17.0 ns 17.0 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_stddev 0.396 ns 0.395 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890";_cv 2.34 % 2.33 % 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_mean 3.01 ns 3.01 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_median 3.02 ns 3.02 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_stddev 0.056 ns 0.056 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890";_cv 1.85 % 1.85 % 10
|
||||
----- Create copy of Str with 9 symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "Test text"; auto c{e};_mean 2.27 ns 2.27 ns 10
|
||||
std::string e = "Test text"; auto c{e};_median 2.25 ns 2.25 ns 10
|
||||
std::string e = "Test text"; auto c{e};_stddev 0.050 ns 0.050 ns 10
|
||||
std::string e = "Test text"; auto c{e};_cv 2.19 % 2.19 % 10
|
||||
std::string_view e = "Test text"; auto c{e};_mean 1.26 ns 1.26 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_median 1.25 ns 1.25 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_stddev 0.035 ns 0.035 ns 10
|
||||
std::string_view e = "Test text"; auto c{e};_cv 2.77 % 2.77 % 10
|
||||
ssa e = "Test text"; auto c{e};_mean 1.27 ns 1.27 ns 10
|
||||
ssa e = "Test text"; auto c{e};_median 1.26 ns 1.26 ns 10
|
||||
ssa e = "Test text"; auto c{e};_stddev 0.042 ns 0.042 ns 10
|
||||
ssa e = "Test text"; auto c{e};_cv 3.31 % 3.31 % 10
|
||||
stringa e = "Test text"; auto c{e};_mean 2.64 ns 2.64 ns 10
|
||||
stringa e = "Test text"; auto c{e};_median 2.64 ns 2.64 ns 10
|
||||
stringa e = "Test text"; auto c{e};_stddev 0.056 ns 0.056 ns 10
|
||||
stringa e = "Test text"; auto c{e};_cv 2.12 % 2.12 % 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_mean 14.1 ns 14.1 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_median 14.0 ns 14.0 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_stddev 0.634 ns 0.634 ns 10
|
||||
lstringa<20> e = "Test text"; auto c{e};_cv 4.49 % 4.49 % 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_mean 14.2 ns 14.2 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_median 14.3 ns 14.3 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_stddev 0.671 ns 0.671 ns 10
|
||||
lstringa<40> e = "Test text"; auto c{e};_cv 4.73 % 4.73 % 10
|
||||
----- Create copy of Str with 30 symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_mean 34.3 ns 34.3 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_median 34.4 ns 34.4 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_stddev 2.04 ns 2.04 ns 10
|
||||
std::string e = "123456789012345678901234567890"; auto c{e};_cv 5.95 % 5.95 % 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_mean 1.25 ns 1.25 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_median 1.24 ns 1.24 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_stddev 0.021 ns 0.021 ns 10
|
||||
std::string_view e = "123456789012345678901234567890"; auto c{e};_cv 1.68 % 1.68 % 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_mean 1.01 ns 1.01 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_median 1.01 ns 1.01 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_stddev 0.018 ns 0.018 ns 10
|
||||
ssa e = "123456789012345678901234567890"; auto c{e};_cv 1.78 % 1.78 % 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_mean 2.66 ns 2.66 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_median 2.66 ns 2.66 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_stddev 0.041 ns 0.041 ns 10
|
||||
stringa e = "123456789012345678901234567890"; auto c{e};_cv 1.53 % 1.53 % 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_mean 17.2 ns 17.2 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_median 17.3 ns 17.3 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_stddev 0.371 ns 0.371 ns 10
|
||||
lstringa<20> e = "123456789012345678901234567890"; auto c{e};_cv 2.15 % 2.15 % 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_mean 13.9 ns 13.9 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_median 13.7 ns 13.7 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_stddev 1.21 ns 1.21 ns 10
|
||||
lstringa<40> e = "123456789012345678901234567890"; auto c{e};_cv 8.68 % 8.68 % 10
|
||||
----- Find 9 symbols text in end of 99 symbols text ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string::find;_mean 54.3 ns 54.3 ns 10
|
||||
std::string::find;_median 54.4 ns 54.4 ns 10
|
||||
std::string::find;_stddev 1.00 ns 1.00 ns 10
|
||||
std::string::find;_cv 1.85 % 1.85 % 10
|
||||
std::string_view::find;_mean 53.4 ns 53.4 ns 10
|
||||
std::string_view::find;_median 53.3 ns 53.3 ns 10
|
||||
std::string_view::find;_stddev 0.764 ns 0.764 ns 10
|
||||
std::string_view::find;_cv 1.43 % 1.43 % 10
|
||||
ssa::find;_mean 52.7 ns 52.7 ns 10
|
||||
ssa::find;_median 52.9 ns 52.9 ns 10
|
||||
ssa::find;_stddev 0.944 ns 0.944 ns 10
|
||||
ssa::find;_cv 1.79 % 1.79 % 10
|
||||
stringa::find;_mean 53.8 ns 53.8 ns 10
|
||||
stringa::find;_median 53.7 ns 53.7 ns 10
|
||||
stringa::find;_stddev 1.24 ns 1.24 ns 10
|
||||
stringa::find;_cv 2.30 % 2.30 % 10
|
||||
lstringa<20>::find;_mean 52.5 ns 52.5 ns 10
|
||||
lstringa<20>::find;_median 52.3 ns 52.3 ns 10
|
||||
lstringa<20>::find;_stddev 1.02 ns 1.02 ns 10
|
||||
lstringa<20>::find;_cv 1.94 % 1.94 % 10
|
||||
lstringa<40>::find;_mean 52.6 ns 52.6 ns 10
|
||||
lstringa<40>::find;_median 52.8 ns 52.8 ns 10
|
||||
lstringa<40>::find;_stddev 0.944 ns 0.944 ns 10
|
||||
lstringa<40>::find;_cv 1.79 % 1.79 % 10
|
||||
------- Copy not literal Str with N symbols ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string copy{str_with_len_N};/15_mean 35.9 ns 35.9 ns 10
|
||||
std::string copy{str_with_len_N};/15_median 35.7 ns 35.7 ns 10
|
||||
std::string copy{str_with_len_N};/15_stddev 2.19 ns 2.19 ns 10
|
||||
std::string copy{str_with_len_N};/15_cv 6.10 % 6.10 % 10
|
||||
std::string copy{str_with_len_N};/16_mean 35.4 ns 35.4 ns 10
|
||||
std::string copy{str_with_len_N};/16_median 35.0 ns 35.0 ns 10
|
||||
std::string copy{str_with_len_N};/16_stddev 2.38 ns 2.38 ns 10
|
||||
std::string copy{str_with_len_N};/16_cv 6.72 % 6.72 % 10
|
||||
std::string copy{str_with_len_N};/23_mean 36.3 ns 36.3 ns 10
|
||||
std::string copy{str_with_len_N};/23_median 36.1 ns 36.1 ns 10
|
||||
std::string copy{str_with_len_N};/23_stddev 2.00 ns 2.00 ns 10
|
||||
std::string copy{str_with_len_N};/23_cv 5.51 % 5.51 % 10
|
||||
std::string copy{str_with_len_N};/24_mean 35.6 ns 35.6 ns 10
|
||||
std::string copy{str_with_len_N};/24_median 36.2 ns 36.2 ns 10
|
||||
std::string copy{str_with_len_N};/24_stddev 2.33 ns 2.33 ns 10
|
||||
std::string copy{str_with_len_N};/24_cv 6.53 % 6.53 % 10
|
||||
std::string copy{str_with_len_N};/32_mean 39.4 ns 39.4 ns 10
|
||||
std::string copy{str_with_len_N};/32_median 38.5 ns 38.5 ns 10
|
||||
std::string copy{str_with_len_N};/32_stddev 3.37 ns 3.37 ns 10
|
||||
std::string copy{str_with_len_N};/32_cv 8.55 % 8.55 % 10
|
||||
std::string copy{str_with_len_N};/64_mean 39.6 ns 39.6 ns 10
|
||||
std::string copy{str_with_len_N};/64_median 38.5 ns 38.5 ns 10
|
||||
std::string copy{str_with_len_N};/64_stddev 3.59 ns 3.59 ns 10
|
||||
std::string copy{str_with_len_N};/64_cv 9.06 % 9.06 % 10
|
||||
std::string copy{str_with_len_N};/128_mean 41.3 ns 41.3 ns 10
|
||||
std::string copy{str_with_len_N};/128_median 41.4 ns 41.4 ns 10
|
||||
std::string copy{str_with_len_N};/128_stddev 2.50 ns 2.50 ns 10
|
||||
std::string copy{str_with_len_N};/128_cv 6.05 % 6.05 % 10
|
||||
std::string copy{str_with_len_N};/256_mean 58.6 ns 58.6 ns 10
|
||||
std::string copy{str_with_len_N};/256_median 64.1 ns 64.1 ns 10
|
||||
std::string copy{str_with_len_N};/256_stddev 13.0 ns 13.0 ns 10
|
||||
std::string copy{str_with_len_N};/256_cv 22.24 % 22.24 % 10
|
||||
std::string copy{str_with_len_N};/512_mean 53.9 ns 53.9 ns 10
|
||||
std::string copy{str_with_len_N};/512_median 53.5 ns 53.5 ns 10
|
||||
std::string copy{str_with_len_N};/512_stddev 11.7 ns 11.7 ns 10
|
||||
std::string copy{str_with_len_N};/512_cv 21.69 % 21.69 % 10
|
||||
std::string copy{str_with_len_N};/1024_mean 53.1 ns 53.1 ns 10
|
||||
std::string copy{str_with_len_N};/1024_median 51.3 ns 51.3 ns 10
|
||||
std::string copy{str_with_len_N};/1024_stddev 7.15 ns 7.15 ns 10
|
||||
std::string copy{str_with_len_N};/1024_cv 13.46 % 13.46 % 10
|
||||
std::string copy{str_with_len_N};/2048_mean 77.9 ns 77.9 ns 10
|
||||
std::string copy{str_with_len_N};/2048_median 77.8 ns 77.8 ns 10
|
||||
std::string copy{str_with_len_N};/2048_stddev 3.38 ns 3.38 ns 10
|
||||
std::string copy{str_with_len_N};/2048_cv 4.34 % 4.34 % 10
|
||||
std::string copy{str_with_len_N};/4096_mean 130 ns 130 ns 10
|
||||
std::string copy{str_with_len_N};/4096_median 132 ns 132 ns 10
|
||||
std::string copy{str_with_len_N};/4096_stddev 7.79 ns 7.79 ns 10
|
||||
std::string copy{str_with_len_N};/4096_cv 5.99 % 5.99 % 10
|
||||
stringa copy{str_with_len_N};/15_mean 2.64 ns 2.64 ns 10
|
||||
stringa copy{str_with_len_N};/15_median 2.63 ns 2.63 ns 10
|
||||
stringa copy{str_with_len_N};/15_stddev 0.060 ns 0.060 ns 10
|
||||
stringa copy{str_with_len_N};/15_cv 2.26 % 2.27 % 10
|
||||
stringa copy{str_with_len_N};/16_mean 4.98 ns 4.98 ns 10
|
||||
stringa copy{str_with_len_N};/16_median 5.00 ns 5.00 ns 10
|
||||
stringa copy{str_with_len_N};/16_stddev 0.113 ns 0.113 ns 10
|
||||
stringa copy{str_with_len_N};/16_cv 2.27 % 2.27 % 10
|
||||
stringa copy{str_with_len_N};/23_mean 5.00 ns 5.00 ns 10
|
||||
stringa copy{str_with_len_N};/23_median 4.95 ns 4.95 ns 10
|
||||
stringa copy{str_with_len_N};/23_stddev 0.234 ns 0.234 ns 10
|
||||
stringa copy{str_with_len_N};/23_cv 4.68 % 4.68 % 10
|
||||
stringa copy{str_with_len_N};/24_mean 5.02 ns 5.02 ns 10
|
||||
stringa copy{str_with_len_N};/24_median 4.98 ns 4.98 ns 10
|
||||
stringa copy{str_with_len_N};/24_stddev 0.122 ns 0.122 ns 10
|
||||
stringa copy{str_with_len_N};/24_cv 2.43 % 2.43 % 10
|
||||
stringa copy{str_with_len_N};/32_mean 4.98 ns 4.98 ns 10
|
||||
stringa copy{str_with_len_N};/32_median 4.92 ns 4.92 ns 10
|
||||
stringa copy{str_with_len_N};/32_stddev 0.146 ns 0.146 ns 10
|
||||
stringa copy{str_with_len_N};/32_cv 2.93 % 2.93 % 10
|
||||
stringa copy{str_with_len_N};/64_mean 4.94 ns 4.94 ns 10
|
||||
stringa copy{str_with_len_N};/64_median 4.97 ns 4.97 ns 10
|
||||
stringa copy{str_with_len_N};/64_stddev 0.094 ns 0.092 ns 10
|
||||
stringa copy{str_with_len_N};/64_cv 1.90 % 1.87 % 10
|
||||
stringa copy{str_with_len_N};/128_mean 4.99 ns 4.99 ns 10
|
||||
stringa copy{str_with_len_N};/128_median 4.98 ns 4.98 ns 10
|
||||
stringa copy{str_with_len_N};/128_stddev 0.139 ns 0.139 ns 10
|
||||
stringa copy{str_with_len_N};/128_cv 2.79 % 2.79 % 10
|
||||
stringa copy{str_with_len_N};/256_mean 4.90 ns 4.90 ns 10
|
||||
stringa copy{str_with_len_N};/256_median 4.90 ns 4.90 ns 10
|
||||
stringa copy{str_with_len_N};/256_stddev 0.092 ns 0.092 ns 10
|
||||
stringa copy{str_with_len_N};/256_cv 1.89 % 1.89 % 10
|
||||
stringa copy{str_with_len_N};/512_mean 5.01 ns 5.01 ns 10
|
||||
stringa copy{str_with_len_N};/512_median 5.00 ns 5.00 ns 10
|
||||
stringa copy{str_with_len_N};/512_stddev 0.119 ns 0.119 ns 10
|
||||
stringa copy{str_with_len_N};/512_cv 2.37 % 2.37 % 10
|
||||
stringa copy{str_with_len_N};/1024_mean 5.07 ns 5.07 ns 10
|
||||
stringa copy{str_with_len_N};/1024_median 5.06 ns 5.06 ns 10
|
||||
stringa copy{str_with_len_N};/1024_stddev 0.146 ns 0.146 ns 10
|
||||
stringa copy{str_with_len_N};/1024_cv 2.87 % 2.87 % 10
|
||||
stringa copy{str_with_len_N};/2048_mean 5.01 ns 5.01 ns 10
|
||||
stringa copy{str_with_len_N};/2048_median 5.00 ns 5.00 ns 10
|
||||
stringa copy{str_with_len_N};/2048_stddev 0.095 ns 0.095 ns 10
|
||||
stringa copy{str_with_len_N};/2048_cv 1.91 % 1.91 % 10
|
||||
stringa copy{str_with_len_N};/4096_mean 4.92 ns 4.92 ns 10
|
||||
stringa copy{str_with_len_N};/4096_median 4.89 ns 4.89 ns 10
|
||||
stringa copy{str_with_len_N};/4096_stddev 0.137 ns 0.137 ns 10
|
||||
stringa copy{str_with_len_N};/4096_cv 2.80 % 2.80 % 10
|
||||
lstringa<16> copy{str_with_len_N};/15_mean 14.1 ns 14.1 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_median 14.2 ns 14.2 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_stddev 0.738 ns 0.738 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/15_cv 5.24 % 5.24 % 10
|
||||
lstringa<16> copy{str_with_len_N};/16_mean 14.6 ns 14.6 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_median 14.7 ns 14.7 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_stddev 0.858 ns 0.858 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/16_cv 5.88 % 5.88 % 10
|
||||
lstringa<16> copy{str_with_len_N};/23_mean 31.6 ns 31.6 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_median 31.4 ns 31.4 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_stddev 1.59 ns 1.59 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/23_cv 5.04 % 5.04 % 10
|
||||
lstringa<16> copy{str_with_len_N};/24_mean 30.9 ns 30.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_median 31.3 ns 31.3 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_stddev 0.895 ns 0.895 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/24_cv 2.89 % 2.89 % 10
|
||||
lstringa<16> copy{str_with_len_N};/32_mean 35.1 ns 35.1 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_median 35.5 ns 35.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_stddev 1.74 ns 1.74 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/32_cv 4.96 % 4.96 % 10
|
||||
lstringa<16> copy{str_with_len_N};/64_mean 34.9 ns 34.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_median 34.9 ns 34.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_stddev 1.80 ns 1.80 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/64_cv 5.16 % 5.16 % 10
|
||||
lstringa<16> copy{str_with_len_N};/128_mean 35.5 ns 35.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_median 34.9 ns 34.9 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_stddev 2.20 ns 2.20 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/128_cv 6.19 % 6.19 % 10
|
||||
lstringa<16> copy{str_with_len_N};/256_mean 54.3 ns 54.3 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_median 60.1 ns 60.1 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_stddev 13.2 ns 13.2 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/256_cv 24.32 % 24.32 % 10
|
||||
lstringa<16> copy{str_with_len_N};/512_mean 48.8 ns 48.8 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_median 48.2 ns 48.2 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_stddev 12.5 ns 12.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/512_cv 25.63 % 25.63 % 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_mean 48.6 ns 48.6 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_median 44.8 ns 44.8 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_stddev 9.55 ns 9.55 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/1024_cv 19.65 % 19.65 % 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_mean 71.5 ns 71.5 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_median 72.0 ns 72.0 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_stddev 2.92 ns 2.92 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/2048_cv 4.09 % 4.09 % 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_mean 118 ns 118 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_median 119 ns 119 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_stddev 4.85 ns 4.85 ns 10
|
||||
lstringa<16> copy{str_with_len_N};/4096_cv 4.12 % 4.12 % 10
|
||||
lstringa<512> copy{str_with_len_N};/15_mean 15.2 ns 15.2 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_median 15.5 ns 15.5 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_stddev 0.706 ns 0.706 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/15_cv 4.63 % 4.63 % 10
|
||||
lstringa<512> copy{str_with_len_N};/16_mean 15.3 ns 15.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_median 15.2 ns 15.2 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_stddev 1.27 ns 1.27 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/16_cv 8.27 % 8.27 % 10
|
||||
lstringa<512> copy{str_with_len_N};/23_mean 14.6 ns 14.6 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_median 14.5 ns 14.5 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_stddev 1.07 ns 1.07 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/23_cv 7.30 % 7.30 % 10
|
||||
lstringa<512> copy{str_with_len_N};/24_mean 15.2 ns 15.2 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_median 15.0 ns 15.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_stddev 0.835 ns 0.835 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/24_cv 5.50 % 5.50 % 10
|
||||
lstringa<512> copy{str_with_len_N};/32_mean 17.8 ns 17.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_median 18.1 ns 18.1 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_stddev 0.989 ns 0.989 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/32_cv 5.55 % 5.55 % 10
|
||||
lstringa<512> copy{str_with_len_N};/64_mean 18.3 ns 18.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_median 18.5 ns 18.5 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_stddev 0.865 ns 0.864 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/64_cv 4.72 % 4.72 % 10
|
||||
lstringa<512> copy{str_with_len_N};/128_mean 18.8 ns 18.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_median 18.3 ns 18.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_stddev 1.22 ns 1.22 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/128_cv 6.45 % 6.45 % 10
|
||||
lstringa<512> copy{str_with_len_N};/256_mean 20.1 ns 20.1 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_median 19.9 ns 19.9 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_stddev 1.24 ns 1.24 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/256_cv 6.16 % 6.16 % 10
|
||||
lstringa<512> copy{str_with_len_N};/512_mean 26.9 ns 26.9 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_median 26.8 ns 26.8 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_stddev 0.929 ns 0.929 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/512_cv 3.45 % 3.45 % 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_mean 48.0 ns 48.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_median 44.6 ns 44.6 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_stddev 7.96 ns 7.96 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/1024_cv 16.59 % 16.59 % 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_mean 71.3 ns 71.3 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_median 71.0 ns 71.0 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_stddev 3.84 ns 3.84 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/2048_cv 5.38 % 5.38 % 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_mean 120 ns 120 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_median 122 ns 122 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_stddev 5.12 ns 5.12 ns 10
|
||||
lstringa<512> copy{str_with_len_N};/4096_cv 4.27 % 4.27 % 10
|
||||
----- Convert to int '1234567' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_mean 69.5 ns 69.5 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_median 69.6 ns 69.6 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_stddev 2.36 ns 2.36 ns 10
|
||||
std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);_cv 3.39 % 3.39 % 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_mean 28.4 ns 28.4 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_median 28.0 ns 28.0 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_stddev 0.994 ns 0.994 ns 10
|
||||
std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);_cv 3.51 % 3.51 % 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 19.0 ns 19.0 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_median 19.0 ns 19.0 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 0.550 ns 0.550 ns 10
|
||||
stringa s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 2.89 % 2.89 % 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 17.3 ns 17.3 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_median 17.2 ns 17.2 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 0.520 ns 0.520 ns 10
|
||||
ssa s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 3.00 % 3.00 % 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_mean 17.4 ns 17.4 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_median 17.4 ns 17.4 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_stddev 0.349 ns 0.349 ns 10
|
||||
lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>_cv 2.00 % 2.00 % 10
|
||||
----- Convert to unsigned 'abcDef' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_mean 54.6 ns 54.6 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_median 54.5 ns 54.5 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_stddev 1.46 ns 1.46 ns 10
|
||||
std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);_cv 2.67 % 2.67 % 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_mean 30.6 ns 30.6 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_median 30.6 ns 30.6 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_stddev 0.742 ns 0.742 ns 10
|
||||
std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);_cv 2.43 % 2.43 % 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 17.9 ns 17.9 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 18.0 ns 18.0 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 0.451 ns 0.451 ns 10
|
||||
stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 2.51 % 2.51 % 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 16.8 ns 16.8 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 16.8 ns 16.8 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 0.368 ns 0.368 ns 10
|
||||
ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 2.19 % 2.19 % 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_mean 16.8 ns 16.8 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_median 16.8 ns 16.8 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_stddev 0.494 ns 0.494 ns 10
|
||||
lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>_cv 2.94 % 2.94 % 10
|
||||
----- Convert to int ' 1234567' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_mean 74.6 ns 74.6 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_median 74.7 ns 74.7 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_stddev 1.85 ns 1.85 ns 10
|
||||
std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);_cv 2.48 % 2.48 % 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_mean 25.4 ns 25.4 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_median 25.3 ns 25.3 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_stddev 0.670 ns 0.670 ns 10
|
||||
stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow_cv 2.64 % 2.64 % 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_mean 23.4 ns 23.4 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_median 23.3 ns 23.3 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_stddev 0.974 ns 0.974 ns 10
|
||||
ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow_cv 4.15 % 4.15 % 10
|
||||
----- Convert to double '1234.567e10' ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_mean 200 ns 200 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_median 200 ns 200 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_stddev 3.85 ns 3.85 ns 10
|
||||
std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);_cv 1.93 % 1.93 % 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_mean 111 ns 111 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_median 112 ns 112 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_stddev 2.42 ns 2.42 ns 10
|
||||
std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);_cv 2.17 % 2.17 % 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_mean 43.1 ns 43.1 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_median 43.3 ns 43.3 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_stddev 0.975 ns 0.975 ns 10
|
||||
ssa s = "1234.567e10"; double res = *s.to_double()_cv 2.26 % 2.26 % 10
|
||||
-- Append const literal of 16 bytes 64 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_mean 4383 ns 4383 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_median 4377 ns 4377 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_stddev 152 ns 152 ns 10
|
||||
std::stringstream str; ... str << "abbaabbaabbaabba";_cv 3.46 % 3.46 % 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_mean 587 ns 587 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_median 587 ns 587 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_stddev 25.0 ns 25.0 ns 10
|
||||
std::string str; ... str += "abbaabbaabbaabba";_cv 4.25 % 4.25 % 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_mean 704 ns 704 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_median 696 ns 696 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_stddev 32.7 ns 32.7 ns 10
|
||||
lstringa<8> str; ... str += "abbaabbaabbaabba";_cv 4.65 % 4.65 % 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_mean 569 ns 569 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_median 564 ns 564 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_stddev 27.9 ns 27.9 ns 10
|
||||
lstringa<128> str; ... str += "abbaabbaabbaabba";_cv 4.90 % 4.90 % 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_mean 516 ns 516 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_median 521 ns 521 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_stddev 20.9 ns 20.9 ns 10
|
||||
lstringa<512> str; ... str += "abbaabbaabbaabba";_cv 4.05 % 4.05 % 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_mean 403 ns 403 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_median 400 ns 400 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_stddev 11.2 ns 11.2 ns 10
|
||||
lstringa<1024> str; ... str += "abbaabbaabbaabba";_cv 2.77 % 2.77 % 10
|
||||
-- Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_mean 4402 ns 4402 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_median 4457 ns 4457 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_stddev 133 ns 133 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba";_cv 3.02 % 3.02 % 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_mean 1940 ns 1940 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_median 1930 ns 1930 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_stddev 97.4 ns 97.4 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba";_cv 5.02 % 5.02 % 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_mean 834 ns 834 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_median 817 ns 817 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_stddev 59.4 ns 59.4 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";_cv 7.12 % 7.12 % 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_mean 698 ns 698 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_median 718 ns 718 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_stddev 46.3 ns 46.3 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";_cv 6.62 % 6.62 % 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_mean 592 ns 592 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_median 594 ns 594 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_stddev 26.6 ns 26.6 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";_cv 4.49 % 4.49 % 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_mean 546 ns 546 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_median 541 ns 541 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_stddev 30.4 ns 30.4 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";_cv 5.56 % 5.56 % 10
|
||||
-- Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_mean 227747 ns 227748 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_median 227780 ns 227780 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_stddev 7201 ns 7203 ns 10
|
||||
std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times_cv 3.16 % 3.16 % 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 107590 ns 107591 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 109011 ns 109011 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 4697 ns 4696 ns 10
|
||||
std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 4.37 % 4.37 % 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 39528 ns 39528 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 38718 ns 38718 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 2165 ns 2165 ns 10
|
||||
lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 5.48 % 5.48 % 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 38289 ns 38289 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 38168 ns 38168 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 3141 ns 3141 ns 10
|
||||
lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 8.20 % 8.20 % 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 39586 ns 39586 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 39363 ns 39363 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 2349 ns 2349 ns 10
|
||||
lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 5.93 % 5.93 % 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_mean 38827 ns 38828 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_median 38977 ns 38977 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_stddev 2031 ns 2031 ns 10
|
||||
lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times_cv 5.23 % 5.23 % 10
|
||||
-- Append 2 string of 16 bytes 32 times, 1024 total length --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_mean 4714 ns 4714 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_median 4708 ns 4708 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_stddev 244 ns 244 ns 10
|
||||
std::stringstream str; ... str << str_var1 << str_var2;_cv 5.18 % 5.18 % 10
|
||||
std::string str; ... str += str_var1 + str_var2;_mean 2421 ns 2421 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_median 2435 ns 2435 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_stddev 152 ns 152 ns 10
|
||||
std::string str; ... str += str_var1 + str_var2;_cv 6.28 % 6.28 % 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_mean 1187 ns 1187 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_median 1189 ns 1189 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_stddev 55.5 ns 55.5 ns 10
|
||||
lstringa<16> str; ... str += str_var1 + str_var2;_cv 4.68 % 4.68 % 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_mean 1062 ns 1062 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_median 1057 ns 1057 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_stddev 70.9 ns 70.9 ns 10
|
||||
lstringa<128> str; ... str += str_var1 + str_var2;_cv 6.68 % 6.68 % 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_mean 907 ns 907 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_median 916 ns 916 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_stddev 60.9 ns 60.9 ns 10
|
||||
lstringa<512> str; ... str += str_var1 + str_var2;_cv 6.72 % 6.72 % 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_mean 856 ns 856 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_median 833 ns 833 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_stddev 61.9 ns 61.9 ns 10
|
||||
lstringa<1024> str; ... str += str_var1 + str_var2;_cv 7.23 % 7.23 % 10
|
||||
-- Append text, number, text --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::stringstream str; str << "test = " << k << " times";_mean 6369 ns 6369 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_median 6276 ns 6276 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_stddev 289 ns 289 ns 10
|
||||
std::stringstream str; str << "test = " << k << " times";_cv 4.54 % 4.54 % 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_mean 1655 ns 1655 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_median 1661 ns 1661 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_stddev 74.1 ns 74.2 ns 10
|
||||
std::string str = "test = " + std::to_string(k) + " times";_cv 4.48 % 4.48 % 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_mean 2916 ns 2916 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_median 2922 ns 2922 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_stddev 76.1 ns 76.1 ns 10
|
||||
char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;_cv 2.61 % 2.61 % 10
|
||||
std::string str = std::format("test = {} times", k);_mean 2078 ns 2078 ns 10
|
||||
std::string str = std::format("test = {} times", k);_median 2061 ns 2061 ns 10
|
||||
std::string str = std::format("test = {} times", k);_stddev 65.7 ns 65.7 ns 10
|
||||
std::string str = std::format("test = {} times", k);_cv 3.16 % 3.16 % 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_mean 3396 ns 3396 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_median 3379 ns 3379 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_stddev 168 ns 168 ns 10
|
||||
lstringa<8> str; str.format("test = {} times", k);_cv 4.93 % 4.93 % 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_mean 2581 ns 2581 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_median 2579 ns 2579 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_stddev 62.8 ns 62.8 ns 10
|
||||
lstringa<32> str; str.format("test = {} times", k);_cv 2.43 % 2.43 % 10
|
||||
lstringa<8> str = "test = " + k + " times";_mean 610 ns 610 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_median 613 ns 613 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_stddev 30.4 ns 30.4 ns 10
|
||||
lstringa<8> str = "test = " + k + " times";_cv 4.99 % 4.99 % 10
|
||||
lstringa<32> str = "test = " + k + " times";_mean 342 ns 342 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_median 345 ns 345 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_stddev 26.2 ns 26.2 ns 10
|
||||
lstringa<32> str = "test = " + k + " times";_cv 7.68 % 7.68 % 10
|
||||
stringa str = "test = " + k + " times";_mean 562 ns 562 ns 10
|
||||
stringa str = "test = " + k + " times";_median 563 ns 563 ns 10
|
||||
stringa str = "test = " + k + " times";_stddev 23.1 ns 23.1 ns 10
|
||||
stringa str = "test = " + k + " times";_cv 4.11 % 4.11 % 10
|
||||
-- Split text and convert to int --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
std::string::find + substr + std::strtol_mean 651 ns 651 ns 10
|
||||
std::string::find + substr + std::strtol_median 654 ns 654 ns 10
|
||||
std::string::find + substr + std::strtol_stddev 41.4 ns 41.4 ns 10
|
||||
std::string::find + substr + std::strtol_cv 6.36 % 6.36 % 10
|
||||
ssa::splitter + ssa::as_int_mean 279 ns 279 ns 10
|
||||
ssa::splitter + ssa::as_int_median 275 ns 275 ns 10
|
||||
ssa::splitter + ssa::as_int_stddev 11.4 ns 11.4 ns 10
|
||||
ssa::splitter + ssa::as_int_cv 4.09 % 4.09 % 10
|
||||
ssa::splitf + functor_mean 346 ns 346 ns 10
|
||||
ssa::splitf + functor_median 346 ns 346 ns 10
|
||||
ssa::splitf + functor_stddev 5.25 ns 5.25 ns 10
|
||||
ssa::splitf + functor_cv 1.52 % 1.51 % 10
|
||||
-- Replace symbols in text ~400 symbols --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Naive (and wrong) replace symbols with std::string find + replace_mean 3588 ns 3588 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_median 3598 ns 3598 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_stddev 118 ns 118 ns 10
|
||||
Naive (and wrong) replace symbols with std::string find + replace_cv 3.28 % 3.28 % 10
|
||||
replace symbols with std::string find_first_of + replace_mean 4762 ns 4762 ns 10
|
||||
replace symbols with std::string find_first_of + replace_median 4760 ns 4760 ns 10
|
||||
replace symbols with std::string find_first_of + replace_stddev 186 ns 186 ns 10
|
||||
replace symbols with std::string find_first_of + replace_cv 3.90 % 3.90 % 10
|
||||
replace symbols with std::string_view find_first_of + copy_mean 3410 ns 3410 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_median 3378 ns 3378 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_stddev 157 ns 157 ns 10
|
||||
replace symbols with std::string_view find_first_of + copy_cv 4.62 % 4.62 % 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_mean 3466 ns 3466 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_median 3401 ns 3401 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_stddev 160 ns 160 ns 10
|
||||
replace runtime symbols with string expressions and without remembering all search results_cv 4.62 % 4.62 % 10
|
||||
replace runtime symbols with simstr and memorization of all search results_mean 3059 ns 3059 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_median 3055 ns 3055 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_stddev 133 ns 133 ns 10
|
||||
replace runtime symbols with simstr and memorization of all search results_cv 4.35 % 4.35 % 10
|
||||
replace const symbols with string expressions and without remembering all search results_mean 2820 ns 2820 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_median 2814 ns 2814 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_stddev 135 ns 135 ns 10
|
||||
replace const symbols with string expressions and without remembering all search results_cv 4.77 % 4.78 % 10
|
||||
replace const symbols with string expressions and memorization of all search results_mean 2715 ns 2715 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_median 2703 ns 2703 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_stddev 105 ns 105 ns 10
|
||||
replace const symbols with string expressions and memorization of all search results_cv 3.89 % 3.89 % 10
|
||||
-- Replace symbols in text ~40 symbols --/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_mean 475 ns 475 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_median 469 ns 469 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_stddev 21.6 ns 21.6 ns 10
|
||||
Short Naive (and wrong) replace symbols with std::string find + replace_cv 4.55 % 4.55 % 10
|
||||
Short replace symbols with std::string find_first_of + replace_mean 518 ns 518 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_median 511 ns 511 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_stddev 19.0 ns 19.0 ns 10
|
||||
Short replace symbols with std::string find_first_of + replace_cv 3.68 % 3.68 % 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_mean 391 ns 391 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_median 389 ns 389 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_stddev 12.7 ns 12.7 ns 10
|
||||
Short replace symbols with std::string_view find_first_of + copy_cv 3.26 % 3.26 % 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_mean 397 ns 397 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_median 393 ns 393 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_stddev 19.6 ns 19.6 ns 10
|
||||
Short replace runtime symbols with string expressions and without remembering all search results_cv 4.93 % 4.93 % 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_mean 405 ns 405 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_median 405 ns 405 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_stddev 18.7 ns 18.7 ns 10
|
||||
Short replace runtime symbols with simstr and memorization of all search results_cv 4.61 % 4.61 % 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_mean 250 ns 250 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_median 249 ns 249 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_stddev 13.6 ns 13.6 ns 10
|
||||
Short replace const symbols with string expressions and without remembering all search results_cv 5.44 % 5.44 % 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_mean 297 ns 297 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_median 295 ns 295 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_stddev 11.4 ns 11.4 ns 10
|
||||
Short replace const symbols with string expressions and memorization of all search results_cv 3.84 % 3.84 % 10
|
||||
----- Replace All Str To Longer Size ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
replace bb to ---- in std::string|64_mean 382 ns 382 ns 10
|
||||
replace bb to ---- in std::string|64_median 383 ns 383 ns 10
|
||||
replace bb to ---- in std::string|64_stddev 15.2 ns 15.2 ns 10
|
||||
replace bb to ---- in std::string|64_cv 3.99 % 3.99 % 10
|
||||
replace bb to ---- in std::string|256_mean 1410 ns 1410 ns 10
|
||||
replace bb to ---- in std::string|256_median 1390 ns 1390 ns 10
|
||||
replace bb to ---- in std::string|256_stddev 82.5 ns 82.5 ns 10
|
||||
replace bb to ---- in std::string|256_cv 5.85 % 5.85 % 10
|
||||
replace bb to ---- in std::string|512_mean 2725 ns 2725 ns 10
|
||||
replace bb to ---- in std::string|512_median 2729 ns 2729 ns 10
|
||||
replace bb to ---- in std::string|512_stddev 113 ns 113 ns 10
|
||||
replace bb to ---- in std::string|512_cv 4.16 % 4.16 % 10
|
||||
replace bb to ---- in std::string|1024_mean 5829 ns 5829 ns 10
|
||||
replace bb to ---- in std::string|1024_median 5693 ns 5693 ns 10
|
||||
replace bb to ---- in std::string|1024_stddev 352 ns 352 ns 10
|
||||
replace bb to ---- in std::string|1024_cv 6.04 % 6.04 % 10
|
||||
replace bb to ---- in std::string|2048_mean 12920 ns 12920 ns 10
|
||||
replace bb to ---- in std::string|2048_median 12631 ns 12631 ns 10
|
||||
replace bb to ---- in std::string|2048_stddev 610 ns 610 ns 10
|
||||
replace bb to ---- in std::string|2048_cv 4.72 % 4.72 % 10
|
||||
replace bb to ---- in lstringa<8>|64_mean 339 ns 339 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_median 337 ns 337 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_stddev 19.7 ns 19.7 ns 10
|
||||
replace bb to ---- in lstringa<8>|64_cv 5.82 % 5.82 % 10
|
||||
replace bb to ---- in lstringa<8>|256_mean 1065 ns 1065 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_median 1068 ns 1068 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_stddev 44.3 ns 44.3 ns 10
|
||||
replace bb to ---- in lstringa<8>|256_cv 4.16 % 4.16 % 10
|
||||
replace bb to ---- in lstringa<8>|512_mean 1968 ns 1968 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_median 1941 ns 1941 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_stddev 116 ns 116 ns 10
|
||||
replace bb to ---- in lstringa<8>|512_cv 5.89 % 5.89 % 10
|
||||
replace bb to ---- in lstringa<8>|1024_mean 3761 ns 3761 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_median 3764 ns 3764 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_stddev 154 ns 154 ns 10
|
||||
replace bb to ---- in lstringa<8>|1024_cv 4.09 % 4.09 % 10
|
||||
replace bb to ---- in lstringa<8>|2048_mean 7335 ns 7335 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_median 7333 ns 7333 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_stddev 313 ns 313 ns 10
|
||||
replace bb to ---- in lstringa<8>|2048_cv 4.27 % 4.27 % 10
|
||||
replace bb to ---- by init stringa|64_mean 220 ns 220 ns 10
|
||||
replace bb to ---- by init stringa|64_median 217 ns 217 ns 10
|
||||
replace bb to ---- by init stringa|64_stddev 10.4 ns 10.4 ns 10
|
||||
replace bb to ---- by init stringa|64_cv 4.75 % 4.75 % 10
|
||||
replace bb to ---- by init stringa|256_mean 738 ns 738 ns 10
|
||||
replace bb to ---- by init stringa|256_median 734 ns 734 ns 10
|
||||
replace bb to ---- by init stringa|256_stddev 43.6 ns 43.6 ns 10
|
||||
replace bb to ---- by init stringa|256_cv 5.90 % 5.90 % 10
|
||||
replace bb to ---- by init stringa|512_mean 1733 ns 1733 ns 10
|
||||
replace bb to ---- by init stringa|512_median 1728 ns 1728 ns 10
|
||||
replace bb to ---- by init stringa|512_stddev 54.1 ns 54.1 ns 10
|
||||
replace bb to ---- by init stringa|512_cv 3.12 % 3.12 % 10
|
||||
replace bb to ---- by init stringa|1024_mean 3695 ns 3695 ns 10
|
||||
replace bb to ---- by init stringa|1024_median 3717 ns 3717 ns 10
|
||||
replace bb to ---- by init stringa|1024_stddev 156 ns 156 ns 10
|
||||
replace bb to ---- by init stringa|1024_cv 4.22 % 4.22 % 10
|
||||
replace bb to ---- by init stringa|2048_mean 7436 ns 7436 ns 10
|
||||
replace bb to ---- by init stringa|2048_median 7389 ns 7389 ns 10
|
||||
replace bb to ---- by init stringa|2048_stddev 246 ns 246 ns 10
|
||||
replace bb to ---- by init stringa|2048_cv 3.31 % 3.31 % 10
|
||||
----- Replace All Str To Same Size ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
replace bb to -- in std::string|64_mean 270 ns 270 ns 10
|
||||
replace bb to -- in std::string|64_median 272 ns 272 ns 10
|
||||
replace bb to -- in std::string|64_stddev 14.2 ns 14.2 ns 10
|
||||
replace bb to -- in std::string|64_cv 5.28 % 5.28 % 10
|
||||
replace bb to -- in std::string|256_mean 1011 ns 1011 ns 10
|
||||
replace bb to -- in std::string|256_median 1008 ns 1008 ns 10
|
||||
replace bb to -- in std::string|256_stddev 41.5 ns 41.4 ns 10
|
||||
replace bb to -- in std::string|256_cv 4.10 % 4.10 % 10
|
||||
replace bb to -- in std::string|512_mean 1878 ns 1878 ns 10
|
||||
replace bb to -- in std::string|512_median 1887 ns 1887 ns 10
|
||||
replace bb to -- in std::string|512_stddev 27.8 ns 27.8 ns 10
|
||||
replace bb to -- in std::string|512_cv 1.48 % 1.48 % 10
|
||||
replace bb to -- in std::string|1024_mean 3626 ns 3626 ns 10
|
||||
replace bb to -- in std::string|1024_median 3596 ns 3596 ns 10
|
||||
replace bb to -- in std::string|1024_stddev 115 ns 115 ns 10
|
||||
replace bb to -- in std::string|1024_cv 3.18 % 3.18 % 10
|
||||
replace bb to -- in std::string|2048_mean 7194 ns 7194 ns 10
|
||||
replace bb to -- in std::string|2048_median 7224 ns 7224 ns 10
|
||||
replace bb to -- in std::string|2048_stddev 254 ns 254 ns 10
|
||||
replace bb to -- in std::string|2048_cv 3.54 % 3.54 % 10
|
||||
replace bb to -- in lstringa<8>|64_mean 222 ns 222 ns 10
|
||||
replace bb to -- in lstringa<8>|64_median 223 ns 223 ns 10
|
||||
replace bb to -- in lstringa<8>|64_stddev 7.12 ns 7.12 ns 10
|
||||
replace bb to -- in lstringa<8>|64_cv 3.21 % 3.21 % 10
|
||||
replace bb to -- in lstringa<8>|256_mean 775 ns 775 ns 10
|
||||
replace bb to -- in lstringa<8>|256_median 778 ns 778 ns 10
|
||||
replace bb to -- in lstringa<8>|256_stddev 33.2 ns 33.2 ns 10
|
||||
replace bb to -- in lstringa<8>|256_cv 4.28 % 4.28 % 10
|
||||
replace bb to -- in lstringa<8>|512_mean 1461 ns 1461 ns 10
|
||||
replace bb to -- in lstringa<8>|512_median 1458 ns 1458 ns 10
|
||||
replace bb to -- in lstringa<8>|512_stddev 65.3 ns 65.3 ns 10
|
||||
replace bb to -- in lstringa<8>|512_cv 4.47 % 4.47 % 10
|
||||
replace bb to -- in lstringa<8>|1024_mean 2776 ns 2776 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_median 2772 ns 2772 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_stddev 95.9 ns 95.9 ns 10
|
||||
replace bb to -- in lstringa<8>|1024_cv 3.46 % 3.46 % 10
|
||||
replace bb to -- in lstringa<8>|2048_mean 5522 ns 5522 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_median 5632 ns 5632 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_stddev 267 ns 267 ns 10
|
||||
replace bb to -- in lstringa<8>|2048_cv 4.84 % 4.84 % 10
|
||||
replace bb to -- by init stringa|64_mean 180 ns 180 ns 10
|
||||
replace bb to -- by init stringa|64_median 180 ns 180 ns 10
|
||||
replace bb to -- by init stringa|64_stddev 7.12 ns 7.12 ns 10
|
||||
replace bb to -- by init stringa|64_cv 3.97 % 3.97 % 10
|
||||
replace bb to -- by init stringa|256_mean 646 ns 646 ns 10
|
||||
replace bb to -- by init stringa|256_median 639 ns 639 ns 10
|
||||
replace bb to -- by init stringa|256_stddev 40.9 ns 40.9 ns 10
|
||||
replace bb to -- by init stringa|256_cv 6.33 % 6.33 % 10
|
||||
replace bb to -- by init stringa|512_mean 1220 ns 1220 ns 10
|
||||
replace bb to -- by init stringa|512_median 1197 ns 1197 ns 10
|
||||
replace bb to -- by init stringa|512_stddev 51.8 ns 51.8 ns 10
|
||||
replace bb to -- by init stringa|512_cv 4.25 % 4.25 % 10
|
||||
replace bb to -- by init stringa|1024_mean 2371 ns 2371 ns 10
|
||||
replace bb to -- by init stringa|1024_median 2376 ns 2376 ns 10
|
||||
replace bb to -- by init stringa|1024_stddev 86.3 ns 86.3 ns 10
|
||||
replace bb to -- by init stringa|1024_cv 3.64 % 3.64 % 10
|
||||
replace bb to -- by init stringa|2048_mean 4604 ns 4604 ns 10
|
||||
replace bb to -- by init stringa|2048_median 4626 ns 4626 ns 10
|
||||
replace bb to -- by init stringa|2048_stddev 139 ns 139 ns 10
|
||||
replace bb to -- by init stringa|2048_cv 3.03 % 3.03 % 10
|
||||
----- Hash Map insert and find ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
hashStrMapA<size_t> emplace & find stringa;_mean 3162304 ns 3162341 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_median 3150599 ns 3150645 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_stddev 88906 ns 88929 ns 10
|
||||
hashStrMapA<size_t> emplace & find stringa;_cv 2.81 % 2.81 % 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_mean 3370915 ns 3370945 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_median 3347562 ns 3347612 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_stddev 63254 ns 63239 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string;_cv 1.88 % 1.88 % 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_mean 3151333 ns 3151360 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_median 3141930 ns 3141974 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_stddev 51278 ns 51255 ns 10
|
||||
hashStrMapA<size_t> emplace & find ssa;_cv 1.63 % 1.63 % 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_mean 3797453 ns 3797464 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_median 3810615 ns 3810615 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_stddev 66726 ns 66718 ns 10
|
||||
std::unordered_map<std::string, size_t> emplace & find std::string_view;_cv 1.76 % 1.76 % 10
|
||||
----- Build Full Func Name ---------/repeats:1 0.000 ns 0.000 ns 1000000000000
|
||||
Build func full name std::string;_mean 2652 ns 2652 ns 10
|
||||
Build func full name std::string;_median 2680 ns 2680 ns 10
|
||||
Build func full name std::string;_stddev 80.1 ns 80.1 ns 10
|
||||
Build func full name std::string;_cv 3.02 % 3.02 % 10
|
||||
Build func full name std::string 1;_mean 2955 ns 2955 ns 10
|
||||
Build func full name std::string 1;_median 2931 ns 2931 ns 10
|
||||
Build func full name std::string 1;_stddev 128 ns 128 ns 10
|
||||
Build func full name std::string 1;_cv 4.33 % 4.33 % 10
|
||||
Build func full name std::stream;_mean 6584 ns 6584 ns 10
|
||||
Build func full name std::stream;_median 6562 ns 6562 ns 10
|
||||
Build func full name std::stream;_stddev 143 ns 143 ns 10
|
||||
Build func full name std::stream;_cv 2.17 % 2.17 % 10
|
||||
Build func full name stringa;_mean 1274 ns 1274 ns 10
|
||||
Build func full name stringa;_median 1274 ns 1274 ns 10
|
||||
Build func full name stringa;_stddev 82.4 ns 82.4 ns 10
|
||||
Build func full name stringa;_cv 6.47 % 6.47 % 10
|
||||
Build func full name stringa 1;_mean 1576 ns 1576 ns 10
|
||||
Build func full name stringa 1;_median 1547 ns 1547 ns 10
|
||||
Build func full name stringa 1;_stddev 85.2 ns 85.2 ns 10
|
||||
Build func full name stringa 1;_cv 5.40 % 5.40 % 10
|
||||
|
|
@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
|
|||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.3.1
|
||||
PROJECT_NUMBER = 1.4.0
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewers a
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
|
|||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.3.1
|
||||
PROJECT_NUMBER = 1.4.0
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewers a
|
||||
|
|
|
|||
|
|
@ -188,12 +188,15 @@ there was std::string_view. However, now the minimum standard version for the li
|
|||
First, I will talk about the library classes for the strings themselves, and then about how the string concatenation problem is optimally solved in it.
|
||||
|
||||
Several general points:
|
||||
- All classes for working with strings are templated by the type of characters, but it is assumed that the characters can be char, char16_t,
|
||||
char32_t, wchar_t.
|
||||
- All classes for working with strings are templated by the type of characters, but it is assumed that the characters can be `char`, `char8_t`, `char16_t`,
|
||||
`char32_t`, `wchar_t`.
|
||||
- All strings have an explicit length.
|
||||
- The string owner classes store them with a trailing zero at the end, which is not included in the length of the string.
|
||||
- The string itself can contain zero characters, all algorithms work only through the length of the string, without paying attention to them.
|
||||
- The library considers different string types to be "compatible" if they have the same character size.
|
||||
That is, `char` and `char8_t` are always identical, and also in Linux `wchar_t` and `char32_t` are identical, and in Windows `wchar_t` and `char16_t`.
|
||||
- The string owner classes can be initialized with strings of another character type, performing conversion between UTF-8, UTF-16, UTF-32.
|
||||
Moreover, if the strings are of different but compatible types, they are simply copied without conversion.
|
||||
- Built-in tables for the first plane of Unicode are used to change the case of characters and compare strings case-insensitively
|
||||
(up to 0xFFFF). Strings are considered to be represented in UTF-8, UTF-16, UTF-32 encoding, respectively.
|
||||
However, string normalization is not done and situations where changing the case of a character leads to a change in their number are not handled.
|
||||
|
|
@ -214,6 +217,7 @@ Implements all string methods that do not modify the string.
|
|||
|
||||
Aliases:
|
||||
- `ssa` for simple_str\<char\>
|
||||
- `ssb` for simple_str\<char8_t\>
|
||||
- `ssu` for simple_str\<char16_t\>
|
||||
- `ssw` for simple_str\<wchar_t>
|
||||
- `ssuu` for simple_str\<char32_t\>
|
||||
|
|
@ -232,6 +236,7 @@ This allows you to write functions with a single parameter type that accepts any
|
|||
|
||||
Aliases:
|
||||
- `stra` for simple_str_nt\<char>
|
||||
- `strb` for simple_str_nt\<char8_t>
|
||||
- `stru` for simple_str_nt\<char16_t>
|
||||
- `strw` for simple_str_nt\<wchar_t>
|
||||
- `struu` for simple_str_nt\<char32_t>
|
||||
|
|
@ -258,6 +263,7 @@ Like `simple_str`, it implements all methods that do not modify the string.
|
|||
|
||||
Aliases:
|
||||
- `stringa` for sstring\<char>
|
||||
- `stringb` for sstring\<char8_t>
|
||||
- `stringu` for sstring\<char16_t>
|
||||
- `stringw` for sstring\<wchar_t>
|
||||
- `stringuu` for sstring\<char32_t>
|
||||
|
|
@ -309,15 +315,16 @@ Usually we assume the approximate size of the strings we will be working with, a
|
|||
and work with it. At the same time, without fear of buffer overflow, since in this case the string will switch to a dynamic buffer.
|
||||
|
||||
Aliases:
|
||||
- `lstringa<N=16>` for lsrting\<char, N, false>
|
||||
- `lstringu<N=16>` for lsrting\<char16_t, N, false>
|
||||
- `lstringw<N=16>` for lsrting\<wchar_t, N, false>
|
||||
- `lstringuu<N=16>` for lsrting\<char32_t, N, false>
|
||||
- `lstringsa<N=16>` for lsrting\<char, N, true>
|
||||
- `lstringsu<N=16>` for lsrting\<char16_t, N, true>
|
||||
- `lstringsw<N=16>` for lsrting\<wchar_t, N, true>
|
||||
- `lstringsuu<N=16>` for lsrting\<char32_t, N, true>
|
||||
|
||||
- `lstringa<N=15>` for lsrting\<char, N, false>
|
||||
- `lstringb<N=15>` for lsrting\<char8_t, N, false>
|
||||
- `lstringu<N=15>` for lsrting\<char16_t, N, false>
|
||||
- `lstringw<N=15>` for lsrting\<wchar_t, N, false>
|
||||
- `lstringuu<N=15>` for lsrting\<char32_t, N, false>
|
||||
- `lstringsa<N=15>` for lsrting\<char, N, true>
|
||||
- `lstringsb<N=15>` for lsrting\<char8_t, N, true>
|
||||
- `lstringsu<N=15>` for lsrting\<char16_t, N, true>
|
||||
- `lstringsw<N=15>` for lsrting\<wchar_t, N, true>
|
||||
- `lstringsuu<N=15>` for lsrting\<char32_t, N, true>
|
||||
|
||||
A small example of use with explanations:
|
||||
```cpp
|
||||
|
|
@ -419,6 +426,12 @@ The `length` function returns the length of the string, and the `place` function
|
|||
Any owning string (simstr::sstring, simstr::lstring) can be initialized with a string expression — it requests its length,
|
||||
allocates space for storing characters, and passes this space to the string expression, calling its place function.
|
||||
|
||||
In addition, all string expressions included in `simstr` can be converted to standard strings (`std::basic_string`)
|
||||
compatible character types, which allows you to use fast concatenation where replacing `std::string` is not yet possible.
|
||||
Compatible character types are those that match in size.
|
||||
To get a standard string before C++23, using `resize`, and then fill it using `data()`, starting with C++23
|
||||
the more optimal `resize_and_overwrite` is used.
|
||||
|
||||
A template addition function is defined for string expressions:
|
||||
```cpp
|
||||
template<StrExpr A, StrExprForType<typename A::symb_type> B>
|
||||
|
|
@ -449,6 +462,10 @@ string expression, you can reapply `operator +`, forming a chain of several stri
|
|||
and eventually "materialize" the last resulting object, which first calculates the size of the entire total memory for
|
||||
the final result, and then places the nested subexpressions into one buffer.
|
||||
|
||||
The addition operation of string expressions allows you to concatenate string expressions of different but compatible types.
|
||||
That is, in one expression you can mix `""` and `u8""`, in Linux `L""` and `U""`, in Windows `L""` and `u""`
|
||||
character types. There are examples in `tests\test_str.cpp TEST(SimStr, StrPrintfU8)`.
|
||||
|
||||
All string types in the library are themselves string expressions, that is, they can serve as terms in concatenations
|
||||
of string expressions.
|
||||
|
||||
|
|
@ -460,6 +477,27 @@ Example:
|
|||
stringa text = header + " count=" + count + ", done";
|
||||
```
|
||||
|
||||
For standard strings (`std::basic_string` and `std::basic_string_view`) addition operators with strings have also been made
|
||||
expressions, so variables of these types also directly participate in concatenation operations.
|
||||
However, standard strings can only participate directly in string expressions when
|
||||
the other operand is also a string expression. If the other operand is not a string expression,
|
||||
use a unary `operator+` before standard strings to turn `std::basic_string` or `std::basic_string_view`
|
||||
to a string expression.
|
||||
|
||||
Example:
|
||||
```cpp
|
||||
std::string make_text(const std::string& text, std::string_view what, int count) {
|
||||
// + turns text into a string expression, and then they are added together
|
||||
return +text + " " + count + " " + what + e_if(count > 1, "s");
|
||||
// what participates directly as an operand with a string expression
|
||||
}
|
||||
std::string make_answer(const std::string& text, std::string_view what, int count) {
|
||||
return "Answer is: " + +text + " " + count + " " + what + e_if(count > 1, "s");
|
||||
// + turns text into a string expression, and it can be added to the previous string literal
|
||||
}
|
||||
```
|
||||
That is, the unary `+` is only needed somewhere at the beginning of the expression if the other operand is not a string expression.
|
||||
|
||||
There are several types of string expressions "out of the box" for performing various operations on strings:
|
||||
|
||||
#### expr_spaces<CharacterType, NumberOfCharacters, Symbol = ' '>{}
|
||||
|
|
|
|||
|
|
@ -189,12 +189,15 @@
|
|||
Сначала я расскажу о классах библиотеки для самих строк, а потом о том, как в ней оптимально решается задача конкатенации строк.
|
||||
|
||||
Несколько общих моментов:
|
||||
- Все классы для работы со строками шаблонизированы типом символов, но подразумевается, что символы могут быть char, char16_t,
|
||||
char32_t, wchar_t.
|
||||
- Все классы для работы со строками шаблонизированы типом символов, но подразумевается, что символы могут быть `char`, `char8_t`, `char16_t`,
|
||||
`char32_t`, `wchar_t`.
|
||||
- Все строки имеют явную длину.
|
||||
- Классы владельцы строк хранят их с завершающим нулем в конце, который не входит в длину строки.
|
||||
- В самой строке могут содержаться нулевые символы, все алгоритмы работают только через длину строки, не обращая на них внимания.
|
||||
- Библиотека считает разные строковые типы "совместимыми", если они имеют одинаковый размер символов.
|
||||
То есть `char` и `char8_t` всегда тождественны, а также в Linux тождественны `wchar_t` и `char32_t`, а в Windows `wchar_t` и `char16_t`.
|
||||
- Классы владельцы строк могут инициализироваться строками другого типа символов, выполняя конвертацию между UTF-8, UTF-16, UTF-32.
|
||||
При этом если строки разных, но совместимых типов, они просто копируются без конвертации.
|
||||
- Для смены регистра символов и сравнения строк без учёта регистра используются встроенные таблицы для первой плоскости юникода
|
||||
(до 0xFFFF). Строки считаются представленными в кодировке UTF-8, UTF-16, UTF-32 соответственно.
|
||||
Однако не делается нормализация строк и не обрабатываются ситуации, когда смена регистра символа приводит к изменению их количества.
|
||||
|
|
@ -215,6 +218,7 @@
|
|||
|
||||
Алиасы:
|
||||
- `ssa` для simple_str\<char\>
|
||||
- `ssb` для simple_str\<char8_t\>
|
||||
- `ssu` для simple_str\<char16_t\>
|
||||
- `ssw` для simple_str\<wchar_t>
|
||||
- `ssuu` для simple_str\<char32_t\>
|
||||
|
|
@ -233,6 +237,7 @@
|
|||
|
||||
Алиасы:
|
||||
- `stra` для simple_str_nt\<char>
|
||||
- `strb` для simple_str_nt\<char8_t>
|
||||
- `stru` для simple_str_nt\<char16_t>
|
||||
- `strw` для simple_str_nt\<wchar_t>
|
||||
- `struu` для simple_str_nt\<char32_t>
|
||||
|
|
@ -259,6 +264,7 @@
|
|||
|
||||
Алиасы:
|
||||
- `stringa` для sstring\<char>
|
||||
- `stringb` для sstring\<char8_t>
|
||||
- `stringu` для sstring\<char16_t>
|
||||
- `stringw` для sstring\<wchar_t>
|
||||
- `stringuu` для sstring\<char32_t>
|
||||
|
|
@ -310,14 +316,16 @@
|
|||
и работать с ней. При этом не опасаясь переполнения буфера, так как в этом случае строка переключится на динамический буфер.
|
||||
|
||||
Алиасы:
|
||||
- `lstringa<N=16>` для lsrting\<char, N, false>
|
||||
- `lstringu<N=16>` для lsrting\<char16_t, N, false>
|
||||
- `lstringw<N=16>` для lsrting\<wchar_t, N, false>
|
||||
- `lstringuu<N=16>` для lsrting\<char32_t, N, false>
|
||||
- `lstringsa<N=16>` для lsrting\<char, N, true>
|
||||
- `lstringsu<N=16>` для lsrting\<char16_t, N, true>
|
||||
- `lstringsw<N=16>` для lsrting\<wchar_t, N, true>
|
||||
- `lstringsuu<N=16>` для lsrting\<char32_t, N, true>
|
||||
- `lstringa<N=15>` для lsrting\<char, N, false>
|
||||
- `lstringb<N=15>` для lsrting\<char8_t, N, false>
|
||||
- `lstringu<N=15>` для lsrting\<char16_t, N, false>
|
||||
- `lstringw<N=15>` для lsrting\<wchar_t, N, false>
|
||||
- `lstringuu<N=15>` для lsrting\<char32_t, N, false>
|
||||
- `lstringsa<N=15>` для lsrting\<char, N, true>
|
||||
- `lstringsb<N=15>` для lsrting\<char8_t, N, true>
|
||||
- `lstringsu<N=15>` для lsrting\<char16_t, N, true>
|
||||
- `lstringsw<N=15>` для lsrting\<wchar_t, N, true>
|
||||
- `lstringsuu<N=15>` для lsrting\<char32_t, N, true>
|
||||
|
||||
|
||||
Небольшой пример использования с пояснениями:
|
||||
|
|
@ -420,6 +428,12 @@
|
|||
Любая владеющая строка (simstr::sstring, simstr::lstring) может инициализироваться строковым выражением — она запрашивает у него длину,
|
||||
выделяет место для хранения символов, и передает это место строковому выражению, вызывая его функцию place.
|
||||
|
||||
Кроме того, все входящие в `simstr` строковые выражения могут преобразовываться в стандартные строки (`std::basic_string`)
|
||||
совместимых типов символов, что позволяет применять быструю конкатенацию там, где заменить `std::string` пока невозможно.
|
||||
Совместимые типы символов - такие, которые совпадают по размеру.
|
||||
Для получения стандартной строки до C++23 используется `resize`, а потом заполнение через `data()`, начиная с C++23
|
||||
используется более оптимальный `resize_and_overwrite`.
|
||||
|
||||
Для строковых выражений определена шаблонная функция сложения:
|
||||
```cpp
|
||||
template<StrExpr A, StrExprForType<typename A::symb_type> B>
|
||||
|
|
@ -450,6 +464,10 @@
|
|||
и в итоге "материализовать" последний получившийся объект, который сначала посчитает размер всей общей памяти для
|
||||
конечного результата, а затем разместит вложенные подвыражения в один буфер.
|
||||
|
||||
Операция сложения строковых выражений позволяет конкатенировать строковые выражения разных, но совместимых типов.
|
||||
То есть в одном выражении вы можете смешивать `""` и `u8""`, в Linux `L""` и `U""`, в Windows `L""` и `u""`
|
||||
типы символов. Примеры есть в `tests\test_str.cpp TEST(SimStr, StrPrintfU8)`.
|
||||
|
||||
Все строковые типы библиотеки сами являются строковыми выражениями, то есть могут служить слагаемыми в конкатенациях
|
||||
строковых выражений.
|
||||
|
||||
|
|
@ -461,6 +479,27 @@
|
|||
stringa text = header + " count=" + count + ", done";
|
||||
```
|
||||
|
||||
Для стандартных строк (`std::basic_string` и `std::basic_string_view`) также сделаны операторы сложения со строковыми
|
||||
выражениями, поэтому переменные этих типов также напрямую участвовать в операциях конкатенирования.
|
||||
Однако cтандартные строки могут напрямую участвовать в строковых выражениях только когда
|
||||
другой операнд тоже является строковым выражением. Если другой операнд - не строковое выражение,
|
||||
используйте перед стандартными строками унарный `operator+`, чтобы превратить `std::basic_string` или `std::basic_string_view`
|
||||
в строковое выражение.
|
||||
|
||||
Пример:
|
||||
```cpp
|
||||
std::string make_text(const std::string& text, std::string_view what, int count) {
|
||||
// + превращает text в строковое выражение, а дальше они уже складываются между собой
|
||||
return +text + " " + count + " " + what + e_if(count > 1, "s");
|
||||
// what участвует уже напрямую как операнд со стороковым выражением
|
||||
}
|
||||
std::string make_answer(const std::string& text, std::string_view what, int count) {
|
||||
return "Answer is: " + +text + " " + count + " " + what + e_if(count > 1, "s");
|
||||
// + превращает text в строковое выражени, и оно может быть сложено с предыдущим строковым литералом
|
||||
}
|
||||
```
|
||||
То есть унарный `+` нужен только где-то в начале выражения, если другой операнд не строковое выражение.
|
||||
|
||||
Существует несколько типов строковых выражений "из коробки", для выполнения различных операций со строками:
|
||||
|
||||
#### expr_spaces<ТипСимвола, КоличествоСимволов, Символ = ' '>{}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
322
readme.md
322
readme.md
|
|
@ -1,106 +1,320 @@
|
|||
# simstr - String object and function library
|
||||
<h2>Speed up your work with strings by 2-10 times!</h2>
|
||||
|
||||
[](https://github.com/orefkov/simstr/actions/workflows/cmake-multi-platform.yml)
|
||||
|
||||
Version 1.3.1.
|
||||
Version 1.4.0.
|
||||
|
||||
<span class="obfuscator"><a href="readme_ru.md">On Russian | По-русски</a></span>
|
||||
|
||||
This library contains the modern implementation of several types of string objects and various algorithms for working with strings.
|
||||
This library contains a modern implementation of several types of string objects and various algorithms for working with strings.
|
||||
|
||||
The goal of the library is to make working with strings in C++ as simple and easy as in many other languages, especially
|
||||
scripting languages, while maintaining optimality and performance at the level of C and C++, and even improving them.
|
||||
scripting languages, while maintaining optimal performance at the level of C and C++, and even improving them.
|
||||
|
||||
It's no secret that working with strings in C++ often causes pain. The `std::string` class is often inconvenient or inefficient.
|
||||
Many functions that are usually necessary when working with strings are simply not there, and everyone has to write them themselves.
|
||||
Many functions that are usually needed when working with strings are simply not there, and everyone has to write them themselves.
|
||||
Even concatenating `std::string` and `std::string_view` became possible only with C++26.
|
||||
That's why I started creating this library for myself around 2012, and now I'm ready to share it with all C++ developers.
|
||||
|
||||
This library was not made as a universal combine that "can do everything", I implemented what I had to
|
||||
use at work, trying to do it in the most efficient way, and I modestly hope that I succeeded in something
|
||||
use in my work, trying to do it in the most efficient way, and I modestly hope that I have succeeded in something
|
||||
and will be useful to other people, either directly or as a source of ideas.
|
||||
|
||||
The library does not pretend to be a "change the header and everything works better" solution. I tried to make many methods compatible
|
||||
with `std::string` and `std::string_view`, but I didn't bother with it much. Rewriting old code to work with simstr
|
||||
will require some effort, but I assure you that it will pay off. And writing new code with its use is easy and enjoyable :)
|
||||
The library contains two parts:
|
||||
- Implementation of [*"String Expressions"*](https://orefkov.github.io/simstr/docs_en/overview.html#autotoc_md68) and algorithms for working
|
||||
with constant strings.\
|
||||
To use this part, just take the file `"include/simstr/strexpr.h"` and write in your code
|
||||
```cpp
|
||||
#include "path/to/file/strexpr.h"
|
||||
```
|
||||
This will allow you to use powerful and fast *"string expressions"* for concatenation and string construction for standard string types (`std::basic_string`, `std::basic_string_view`), as well as simplified versions of the `simple_str` and
|
||||
`simple_str_nt` classes, which implement all those string algorithms of the library that do not require storing or modifying strings.
|
||||
Since this is a header-only part, it does not include working with UTF encodings and simplified Unicode.
|
||||
- The full version, which requires connecting the entire library (`"include/simstr/sstring.h"`), adds its own string types with
|
||||
the ability to store and modify strings, works with UTF encodings and simplified Unicode.
|
||||
|
||||
The main difference between simstr and std::string is that instead of a single universal class, several
|
||||
types of objects are used to work with strings, each of which is good for its own purposes, and at the same time interacts well with each other.
|
||||
If you actively used std::string_view and understood its advantages and disadvantages compared to std::string,
|
||||
then the simstr approach will also be clear to you.
|
||||
The library does not pretend to be "changed the header and everything worked better" - it gets along well with standard strings
|
||||
and does not change the behavior of existing code working with them. I tried to make many methods in it compatible
|
||||
with `std::string` and `std::string_view`, but I didn't bother with this much. Rewriting your code to work with `simstr`
|
||||
will require some effort, but I assure you that it will pay off. And thanks to compatibility with standard strings, this work can be done
|
||||
in stages, in small pieces. Creating new code for working with strings with its use is easy and enjoyable :)
|
||||
|
||||
|
||||
The main difference between `simstr` and `std::string` is that not a single universal class is used for working with strings, but several
|
||||
types of objects, each of which is good for its own purposes, and at the same time interact well with each other.
|
||||
If you actively used `std::string_view` and understood its advantages and disadvantages compared to `std::string`,
|
||||
then the `simstr` approach will also be clear to you.
|
||||
|
||||
## Main features of the library
|
||||
- Strings `char`, `char16_t`, `char32_t`, `wchar_t`.
|
||||
- Transparent conversion of strings from one character type to another, with automatic conversion between UTF-8, UTF-16, UTF-32,
|
||||
using [simdutf](https://github.com/simdutf/simdutf).
|
||||
- Extensible "String Expression" system. Allows you to efficiently implement the conversion and addition (concatenation) of strings, literals,
|
||||
numbers and possibly other objects.
|
||||
- String functions:
|
||||
When using only `#include "simstr\strexpr.h"`:
|
||||
- Support for working with strings `char`, `char8_t`, `char16_t`, `char32_t`, `wchar_t`.
|
||||
- Powerful and extensible *"String Expressions"* system.
|
||||
Allows you to efficiently implement the conversion and addition (concatenation) of strings, string literals, numbers (and possibly other objects),
|
||||
achieving significant acceleration of string operations.
|
||||
Compatible with both `simstr` string objects and standard strings (`std::basic_string`,
|
||||
`std::basic_string_view`), which allows you to use fast concatenation even where it is not yet possible to abandon standard strings.
|
||||
Also allows you to mix strings of compatible character types in operations.
|
||||
- Constant string functions (do not change the original string):
|
||||
- Getting substrings.
|
||||
- Comparing strings, comparing strings ignoring the case of ASCII characters.
|
||||
- Searching for substrings and characters - from the beginning or from the end of the string.
|
||||
- Various string trimming - right, left, everywhere, by whitespace characters, by specified characters.
|
||||
- Replacing substrings.
|
||||
- Replacing a set of characters with a set of corresponding substrings.
|
||||
- Merging (join) containers of strings into a single string, with specifying separators and options - "skip empty", "separator after last".
|
||||
- Splitting strings into parts by a specified separator. Splitting is possible directly into a container with strings, or by calling a functor for
|
||||
- Various trimming of strings - right, left, everywhere, by whitespace characters, by specified characters.
|
||||
- Replacing substrings (creating a copy of the string with the replacement).
|
||||
- Replacing a set of characters with a set of corresponding substrings (creating a copy of the string with the replacement).
|
||||
- Merging (join) containers of strings into a single string, with specifying delimiters and options - "skip empty", "delimiter after last".
|
||||
- Splitting strings into parts by a specified delimiter. Splitting is possible immediately into a container with strings, or by calling a functor for
|
||||
each substring, or by iterating using the `Splitter` iterator.
|
||||
- Integration with `format` and `sprintf` formatting functions (with automatic buffer increase).
|
||||
Formatting is possible for `char`, `wchar_t` strings and strings compatible with `wchar_t` in size.
|
||||
That is, under Windows it is `char16_t`, under Linux - `char32_t`. Writing my own formatting library was not part of my plans.
|
||||
- Parsing integers with the possibility of "fine" tuning during compilation - you can set options for checking overflow,
|
||||
skipping whitespace characters, a specific radix or auto-selection by prefixes `0x`, `0`, `0b`, `0o`,
|
||||
- Parsing integers with the possibility of "fine" tuning at compile time - you can set options for checking overflow,
|
||||
skipping whitespace characters, a specific base or auto-selection by prefixes `0x`, `0`, `0b`, `0o`,
|
||||
admissibility of the `+` sign. Parsing is implemented for all types of strings and characters.
|
||||
- Parsing doubles for all types of characters.
|
||||
- Minimal Unicode support is included when converting `upper`, `lower` and case-insensitive string comparison.
|
||||
It only works for characters in the first plane of Unicode (up to 0xFFFF), and when changing case, it does not take into account cases where one code point
|
||||
- Parsing double for `char` and `wchar_t`, as well as character types compatible with them in size.
|
||||
|
||||
When using the full version of the library:
|
||||
- Everything that is listed above, plus
|
||||
- Additional efficient string objects - `sstring` (shared string), `lstring` (local string).
|
||||
- `lstring` - supports many mutable operations with strings - various replacements, insertions, deletions, etc.
|
||||
Allows you to set the size for the internal character buffer, which can turn *Small String Optimization* into *Big String Optimization* :).
|
||||
- Transparent conversion of strings from one character type to another, with automatic conversion between UTF-8, UTF-16, UTF-32,
|
||||
using [simdutf](https://github.com/simdutf/simdutf). Strings of "compatible" types are converted by simple copying:
|
||||
`char <-> char8_t`, `wchar_t <-> char32_t` in Linux, `wchar_t <-> char16_t` in Windows.
|
||||
- Integration with `format` and `sprintf` formatting functions (with automatic buffer increase).
|
||||
Formatting is possible for `char`, `wchar_t` strings and strings compatible with them in size.
|
||||
That is, under Windows it is `char8_t`, `char16_t`, under Linux - `char8_t`, `char32_t` (writing my own formatting library for all types of
|
||||
characters was not part of my plans).
|
||||
- Contains minimal Unicode support when converting `upper`, `lower` and case-insensitive string comparison.
|
||||
Works only for characters of the first Unicode plane (up to 0xFFFF), and when changing the case, cases are not taken into account when one code point
|
||||
can be converted into several, that is, the case conversion of characters corresponds to `std::towupper`, `std::towlower` for the unicode locale, only faster and can work with any type of characters.
|
||||
- Implemented `hash map` for string type keys, based on `std::unordered_map`, with the possibility of more efficient storage and
|
||||
comparison of keys compared to `std::string` keys. Case-insensitive key comparison is supported (Ascii or
|
||||
comparison of keys compared to `std::string` keys. The possibility of case-insensitive comparison of keys is supported (Ascii or
|
||||
minimal Unicode (see previous paragraph)).
|
||||
|
||||
## String expressions
|
||||
These are special objects that efficiently implement string concatenation using `operator+`.
|
||||
The main principle, due to which efficient work is achieved - no matter how many operands are included in the entire expression,
|
||||
no temporary (intermediate) strings are created, the total length of the entire result is calculated only once,
|
||||
memory is allocated for the character buffer of the result only once, after which the characters are copied immediately to the buffer of the result
|
||||
to its place. No memory reallocations, no moving characters in various intermediate buffers - everything is
|
||||
as efficient as possible. Thanks to the capabilities of C++ templates and operator overloading, the expression is written as close as possible
|
||||
to the usual string addition syntax.
|
||||
In addition, there are special overloads for adding string objects and string literals, strings and numbers,
|
||||
for copying with replacement, for merging containers of strings and much more.
|
||||
Thanks to the extensibility of this system, it is possible to create new options for building strings, development is constantly ongoing.
|
||||
|
||||
All string objects from `simstr` are themselves string expressions, that is, they can be used in concatenation operations
|
||||
of string expressions directly. Standard strings (`std::basic_string`, `std::basic_string_view`) can also serve as operands
|
||||
in addition operations with string expressions. Or they can be easily converted into a string expression by placing a
|
||||
unary `+` in front of them.
|
||||
|
||||
## Usage examples
|
||||
### Adding strings with numbers
|
||||
```cpp
|
||||
std::string s1 = "start ";
|
||||
int i;
|
||||
....
|
||||
// Was
|
||||
std::string str = s1 + std::to_string(i) + " end";
|
||||
// Became
|
||||
std::string str = +s1 + i + " end";
|
||||
```
|
||||
`+s1` - converts `std::string` into an object - a string expression, for which there is an efficient concatenation with numbers and string literals.
|
||||
|
||||
According to benchmarks, [acceleration is 1.6 - 2 times](https://orefkov.github.io/simstr/results.html#bs70109915512075798510).
|
||||
|
||||
### Adding strings with numbers in hex format
|
||||
```cpp
|
||||
....
|
||||
// Was
|
||||
std::string str = s1 + std::format("0x{:x}", i) + " end";
|
||||
// Became
|
||||
std::string str = +s1 + e_hex<HexFlags::Short>(i) + " end";
|
||||
```
|
||||
Acceleration in [**9 - 14 times!!!**](https://orefkov.github.io/simstr/results.html#bs146911715078927772520)
|
||||
|
||||
### Adding multiple literals and searching in `std::string_view`
|
||||
```cpp
|
||||
// It was like this
|
||||
size_t find_pos(std::string_view src, std::string_view name) {
|
||||
// before C++26 we can not concatenate string and string_view...
|
||||
return src.find("\n- "s + std::string{name} + " -\n");
|
||||
}
|
||||
// When using only "strexpr.h" it became like this
|
||||
size_t find_pos(ssa src, ssa name) {
|
||||
return src.find(std::string{"\n- " + name + " -\n"});
|
||||
}
|
||||
|
||||
// And when using the full library, you can do this
|
||||
size_t find_pos(ssa src, ssa name) {
|
||||
// In this version, if the result of the concatenation fits into 207 characters, it is produced in a buffer on the stack,
|
||||
// without allocation and deallocation of memory, acceleration is several times. And only if the result is longer than 207 characters -
|
||||
// there will be only one allocation, and the concatenation will be immediately into the allocated buffer, without copying characters.
|
||||
return src.find(lstringa<200>{"\n- " + name + " -\n"});
|
||||
}
|
||||
```
|
||||
`ssa` - alias for `simple_str<char>` - analogue of `std::string_view`, allows you to accept any string object as a function parameter with minimal costs,
|
||||
which does not need to be modified or passed to the C-API: `std::string`, `std::string_view`, `"string literal"`,
|
||||
`simple_str_nt`, `sstring`, `lstring`. Also, since it is also a "string expression", it allows you to easily
|
||||
build concatenations with its participation.
|
||||
|
||||
According to measurements, [acceleration is 1.5 - 9 times](https://orefkov.github.io/simstr/results.html#bs68116594352702954700).
|
||||
|
||||
### Addition with conditions
|
||||
```cpp
|
||||
// Was
|
||||
std::string buildTypeName(std::string_view type_name, size_t prec, size_t scale) {
|
||||
std::string res{type_name};
|
||||
if (prec) {
|
||||
res += "(" + std::to_string(prec);
|
||||
if (scale) {
|
||||
res += "," + std::to_string(scale);
|
||||
}
|
||||
res += ")";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Became when using only strexpr.h and wanting to use only standard strings
|
||||
std::string buildTypeName(std::string_view type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
// + turns type_name from string_view into a string expression
|
||||
return +type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
// Became when using only strexpr.h and simple_str string
|
||||
std::string buildTypeName(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
// ssa is already a string expression, + before it is not needed
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
// Became when using the full library
|
||||
stringa buildTypeName(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
```
|
||||
When `prec != 0`, [acceleration is 1.5 - 2.2 times](https://orefkov.github.io/simstr/results.html#bs145290966789248325200).
|
||||
|
||||
### Addition with replacements
|
||||
```cpp
|
||||
// Was
|
||||
// There is no standard analogue of the replace function from other programming languages, let's write our own "head-on".
|
||||
std::string str_replace(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
std::string result;
|
||||
for (size_t offset = 0;;) {
|
||||
size_t pos = from.find(pattern, offset);
|
||||
if (pos == std::string::npos) {
|
||||
result += from.substr(offset);
|
||||
break;
|
||||
}
|
||||
result += from.substr(offset, pos - offset);
|
||||
result += repl;
|
||||
offset = pos + pattern.length();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
return "<" + str_replace(from, pattern, repl) + ">";
|
||||
}
|
||||
// Became - copying with replacements
|
||||
std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
return "<" + e_repl(from, pattern, repl) + ">";
|
||||
}
|
||||
```
|
||||
[Acceleration from 1.5 times and higher](https://orefkov.github.io/simstr/results.html#bs54035654251116789780) - depending on the content of the strings.
|
||||
|
||||
### Splitting strings into parts, parsing numbers
|
||||
```cpp
|
||||
// Was - split the string by delimiter and calculate the sum of numbers
|
||||
int split_and_calc_total_str(std::string_view numbers, std::string_view delimiter) {
|
||||
int total = 0;
|
||||
for (size_t start = 0; start < numbers.length(); ) {
|
||||
int delim = numbers.find(delimiter, start);
|
||||
if (delim == std::string::npos) {
|
||||
delim = numbers.size();
|
||||
}
|
||||
std::string part{numbers.substr(start, delim - start)};
|
||||
total += std::strtol(part.c_str(), nullptr, 0);
|
||||
start = delim + delimiter.length();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
// Became
|
||||
int split_and_calc_total_sim(ssa numbers, ssa delimiter) {
|
||||
int total = 0;
|
||||
for (auto splitter = numbers.splitter(delimiter); !splitter.is_done();) {
|
||||
total += splitter.next().as_int<int>();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
```
|
||||
[Acceleration in 2-3 times](https://orefkov.github.io/simstr/results.html#bs7106975351756760120).
|
||||
|
||||
In addition to the individual examples given here, you can look at the sources:
|
||||
- [tests of the entire library](https://github.com/orefkov/simstr/blob/main/tests/test_str.cpp)
|
||||
- [tests of only the strexpr part](https://github.com/orefkov/simstr/blob/main/tests/test_expr_only.cpp)
|
||||
- [benchmarks](https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp)
|
||||
- [utility for preparing html](https://github.com/orefkov/simstr/blob/main/bench/process_result.cpp) from benchmark results.
|
||||
|
||||
## Main objects of the library
|
||||
- simple_str<K> - the simplest string (or piece of string), immutable, not owning, analogue of `std::string_view`.
|
||||
- simple_str_nt<K> - the same, only declares that it ends with 0. For working with third-party C-API.
|
||||
- sstring<K> - shared string, immutable, owning, with shared character buffer, SSO support.
|
||||
- lstring<K, N> - local string, mutable, owning, with a specified size of the SSO buffer.
|
||||
Available with any use:
|
||||
- `simple_str<K>` - the simplest string (or piece of string), immutable, not owning, analogue of `std::string_view`.
|
||||
- `simple_str_nt<K>` - the same, only declares that it ends with 0. For working with third-party C-API.
|
||||
|
||||
Available when using the entire library:
|
||||
- `sstring<K>` - shared string, immutable, owning, with shared character buffer, SSO support.
|
||||
- `lstring<K, N>` - local string, mutable, owning, with a specified size of the SSO buffer.
|
||||
|
||||
When connecting only `strexpr.h` - the types `simple_str<K>` and `simple_str_nt<K>` do not contain methods for working with UTF and Unicode.
|
||||
|
||||
## Articles
|
||||
- [Overview and introduction](docs/overview.md)
|
||||
- [Overview article on Habr](https://habr.com/ru/articles/935590)
|
||||
- [Description of the "Expression Templates" technique used](https://habr.com/ru/articles/936468/)
|
||||
- [Overview article on Habr](https://habr.com/ru/articles/935590) (On Russian)
|
||||
- [Description of the "Expression Templates" technique used](https://habr.com/ru/articles/936468/) (On Russian)
|
||||
|
||||
## Usage
|
||||
`simstr` consists of three header files and two source files. You can connect as a CMake project via `add_subdirectory` (the `simstr` library),
|
||||
The library can be used partially, just by taking the file `"include\simstr\strexpr.h"` and including it in your sources
|
||||
```cpp
|
||||
#include "include\simstr\strexpr.h"
|
||||
```
|
||||
This will only connect string expressions and simplified implementations of `simple_str` and `simple_str_nt`, without UTF and Unicode functions.
|
||||
|
||||
The full version of the `simstr` library consists of three header files and two source files.
|
||||
You can connect as a CMake project via `add_subdirectory` (the `simstr` library),
|
||||
you can simply include the files in your project. Building also requires [simdutf](https://github.com/simdutf/simdutf) (when using CMake
|
||||
it is downloaded automatically).
|
||||
|
||||
The library is included in [vcpkg](https://vcpkg.io), use as `orefkov-simstr`.
|
||||
The library is included in [vcpkg](https://vcpkg.io), connected as `orefkov-simstr`.
|
||||
|
||||
`simstr` requires a compiler of standard no lower than C++20 to work - concepts and std::format are used.
|
||||
`simstr` requires a compiler of at least the C++20 standard - concepts and std::format are used.
|
||||
The work was tested under Windows on MSVC-19 and Clang-19, under Linux - on GCC-13 and Clang-21.
|
||||
The work in WASM was also tested, built in Emscripten 4.0.6, Clang-21.
|
||||
|
||||
|
||||
## Convenient debugging
|
||||
Along with the library, two files are supplied that allow viewing simstr string objects in debuggers
|
||||
Together with the library, two files are supplied that make viewing simstr string objects in debuggers
|
||||
more convenient.\
|
||||
It is described in more detail in [here](for_debug/readme.md).
|
||||
More details are described [here](for_debug/readme_ru.md).
|
||||
|
||||
## Benchmarks
|
||||
Benchmarks are performed using the [Google benchmark](https://github.com/google/benchmark) framework.
|
||||
I tried to make measurements for the most typical operations that occur in normal work. I took measurements on my equipment, under
|
||||
I tried to take measurements for the most typical operations that occur in normal work. I took measurements on my equipment, under
|
||||
Windows and Linux (in WSL), using MSVC, Clang, GCC compilers. Third-party results are welcome.
|
||||
I also took measurements in WASM, built in Emscripten. I draw your attention to the fact that a 32-bit build is assembled under WASM in Emscripten, which means that
|
||||
the sizes of SSO buffers in objects are smaller.
|
||||
|
||||
- [Benchmark source code](bench/bench_str.cpp)
|
||||
- [Benchmark results](https://snegopat.ru/simstr/results.html)
|
||||
- [Source code of benchmarks](bench/bench_str.cpp)
|
||||
- [Benchmark results](https://orefkov.github.io/simstr/results.html)
|
||||
|
||||
## Usage examples
|
||||
While no separate usage examples have been prepared, you can look at the texts of [tests](https://github.com/orefkov/simstr/blob/main/tests/test_str.cpp),
|
||||
[benchmarks](https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp), and
|
||||
[html preparation utilities](https://github.com/orefkov/simstr/blob/main/bench/process_result.cpp) from the benchmark results.
|
||||
|
||||
Also simstr is used in my projects:
|
||||
Also, simstr is used in my projects:
|
||||
- [simjson](https://github.com/orefkov/simjson) - a library for simple work with JSON using simstr strings.
|
||||
- [simrex](https://github.com/orefkov/simrex) - a wrapper for working with [Oniguruma](https://github.com/kkos/oniguruma) regular expressions using simstr strings.
|
||||
- [simrex](https://github.com/orefkov/simrex) - wrapper for working with regular expressions [Oniguruma](https://github.com/kkos/oniguruma) using simstr strings.
|
||||
- [v8sqlite](https://github.com/orefkov/v8sqlite) - external component for 1C-Enterprise V8 for working with sqlite.
|
||||
|
||||
|
||||
## Generated documentation
|
||||
[Located here](https://snegopat.ru/simstr/docs/)
|
||||
[Located here](https://orefkov.github.io/simstr/docs_en/)
|
||||
|
|
|
|||
276
readme_ru.md
276
readme_ru.md
|
|
@ -1,7 +1,9 @@
|
|||
# simstr - библиотека строковых объектов и функций
|
||||
<h2>Ускорь работу со строками в 2-10 раз!</h2>
|
||||
|
||||
[](https://github.com/orefkov/simstr/actions/workflows/cmake-multi-platform.yml)
|
||||
|
||||
Версия 1.3.1.
|
||||
Версия 1.4.0.
|
||||
|
||||
<span class="obfuscator"><a href="readme.md">On English | По-английски</a></span>
|
||||
|
||||
|
|
@ -12,42 +14,75 @@
|
|||
|
||||
Не секрет, что работа со строками в С++ зачастую доставляет боль. Класс `std::string` часто неудобен либо неэффективен.
|
||||
Многих функций, обычно необходимых при работе со строками, просто нет, и их каждому приходится писать самому.
|
||||
Даже элементарно конкатенировать `std::string` и `std::string_view` стало возможно только с C++26.
|
||||
Именно поэтому я начал примерно в 2012 году создавать для себя эту библиотеку, и теперь готов поделится ею со всеми C++ разработчиками.
|
||||
|
||||
Эта библиотека не делалась как универсальный комбайн, который "может всё", я реализовывал то, что мне приходилось
|
||||
использовать в работе, стараясь сделать это наиболее эффективным способом, и скромно надеюсь, что кое-что у меня получилось
|
||||
и пригодится другим людям, либо напрямую, либо как источник идей.
|
||||
|
||||
Библиотека не претендует на роль "поменял хедер и всё заработало лучше". Многие методы я старался делать совместимыми
|
||||
с `std::string` и `std::string_view`, но особо с этим не заморачивался. Переписывание старого кода на работу с simstr
|
||||
потребует некоторых усилий, но уверяю, что они окупятся. А новый код писать с её применением легко и доставляет удовольствие :)
|
||||
Библиотека содержит две части:
|
||||
- Реализация [*"Строковых выражений"*](https://orefkov.github.io/simstr/docs_ru/overview.html#autotoc_md27) и алгоритмов работы
|
||||
с константными строками.\
|
||||
Для использования этой части достаточно просто взять файл `"include/simstr/strexpr.h"` и написать в своём коде
|
||||
```cpp
|
||||
#include "путь/к файлу/strexpr.h"
|
||||
```
|
||||
Это позволит вам для стандартных строковых типов (`std::basic_string`, `std::basic_string_view`) использовать
|
||||
мощные и быстрые *"строковые выражения"* для конкатенации и построения строк, а также упрощенные варианты классов `simple_str` и
|
||||
`simple_str_nt`, которые реализуют все те строковые алгоритмы библиотеки, которые не требуют хранения или модификации строк.
|
||||
Так как это header-only часть, она не включает в себя работу с UTF-кодировками и упрощённый Unicode.
|
||||
- Полная версия, требующая подключения всей библиотеки (`"include/simstr/sstring.h"`), добавляет свои строковые типы с
|
||||
возможностями хранения и модификации строк, работает с UTF-кодировками и упрощённым Unicode.
|
||||
|
||||
Основное отличие simstr от std::string - для работы со строками используется не единый универсальный класс, а несколько
|
||||
Библиотека не претендует на роль "поменял хедер и всё заработало лучше" - она прекрасно уживается вместе со стандартными строками
|
||||
и не меняет поведение уже существующего кода, работающего с ними. Многие методы в ней я старался делать совместимыми
|
||||
с `std::string` и `std::string_view`, но особо с этим не заморачивался. Переписывание вашего кода на работу с `simstr`
|
||||
потребует некоторых усилий, но уверяю, что они окупятся. А благодаря совместимости со стандартными строками эту работу можно делать
|
||||
поэтапно, небольшими кусками. Новый же код работы со строками создавать с её применением легко и доставляет удовольствие :)
|
||||
|
||||
|
||||
Основное отличие `simstr` от `std::string` - для работы со строками используется не единый универсальный класс, а несколько
|
||||
видов объектов, каждый из которых хорош для своих целей, и при этом хорошо взаимодействующих друг с другом.
|
||||
Если вы активно использовали std::string_view и понимали, в чём его преимущество и недостатки по сравнению с std::string,
|
||||
то подход simstr вам также будет понятен.
|
||||
Если вы активно использовали `std::string_view` и понимали, в чём его преимущества и недостатки по сравнению с `std::string`,
|
||||
то подход `simstr` вам также будет понятен.
|
||||
|
||||
## Основные возможности библиотеки
|
||||
- Строки `char`, `char16_t`, `char32_t`, `wchar_t`.
|
||||
- Прозрачное преобразование строк из одного типа символов в другой, с автоматической конвертацией между UTF-8, UTF-16, UTF-32,
|
||||
используя [simdutf](https://github.com/simdutf/simdutf).
|
||||
- Расширяемая система "Строковых выражений". Позволяет эффективно реализовать преобразование и сложение (конкатенацию) строк, литералов,
|
||||
чисел и возможно других объектов.
|
||||
- Строковые функции:
|
||||
При использовании только `#include "simstr\strexpr.h"`:
|
||||
- Поддержка работы со строками `char`, `char8_t`, `char16_t`, `char32_t`, `wchar_t`.
|
||||
- Мощная и расширяемая система *"Строковых выражений"*.
|
||||
Позволяет эффективно реализовать преобразование и сложение (конкатенацию) строк, строковых литералов, чисел (и возможно других объектов),
|
||||
добиваясь значительного ускорения строковых операций.
|
||||
Совместима как со строковыми объектами `simstr`, так и со стандартными строками (`std::basic_string`,
|
||||
`std::basic_string_view`), что позволяет применять быструю конкатенацию и там, где пока не получается отказаться от стандартных строк.
|
||||
Тоже позволяет смешивать в операциях строки совместимых типов символов.
|
||||
- Константные строковые функции (не меняют исходную строку):
|
||||
- Получение подстрок.
|
||||
- Сравнение строк, сравнение строк без учёта регистра ASCII-символов.
|
||||
- Поиск подстрок и символов - с начала или с конца строки.
|
||||
- Различный тримминг строк - справа, слева, везде, по пробельным символам, по заданным символам.
|
||||
- Замена подстрок.
|
||||
- Замена набора символов на набор соответствующих подстрок.
|
||||
- Замена подстрок (созданием копии строки с заменой).
|
||||
- Замена набора символов на набор соответствующих подстрок (созданием копии строки с заменой).
|
||||
- Слияние (join) контейнеров строк в единую строку, с заданием разделителей и опций - "пропускать пустые", "разделитель после последней".
|
||||
- Разбиение (split) строк на части по заданному разделителю. Разбиение возможно сразу в контейнер со строками, либо вызовом функтора для
|
||||
каждой подстроки, либо путем итерации с помощью итератора `Splitter`.
|
||||
- Интеграция с функциями форматирования `format` и `sprintf` (с автоматическим увеличением буфера).
|
||||
Форматирование возможно для строк `char`, `wchar_t` и строк, совместимых с `wchar_t` по размеру.
|
||||
То есть под Windows это `char16_t`, под Linux - `char32_t`. Писать свою библиотеку форматирования не входило в мои замыслы.
|
||||
- Парсинг целых чисел с возможностью "тонкой" настройки при компиляции - можно задавать опции проверки переполнения,
|
||||
пропуск пробельных символов, конкретное основание счисления либо автовыбор по префиксам `0x`, `0`, `0b`, `0o`,
|
||||
допустимость знака `+`. Парсинг реализован для всех видов строк и символов.
|
||||
- Парсинг double для всех типов символов.
|
||||
- Парсинг double для `char` и `wchar_t`, а также совместимых с ними по размеру типов символов.
|
||||
|
||||
При использовании полной версии библиотеки:
|
||||
- Всё то же, что и перечислено выше, плюс
|
||||
- Дополнительные эффективные строковые объекты - `sstring` (shared string), `lstring` (local string).
|
||||
- `lstring` - поддерживает множество мутабельных операций со строками - различные замены, вставки, удаления и т.п.
|
||||
Позволяет задавать размер для внутреннего буфера символов, что может превращать *Small String Optimization* в *Big String Optimization* :).
|
||||
- Прозрачное преобразование строк из одного типа символов в другой, с автоматической конвертацией между UTF-8, UTF-16, UTF-32,
|
||||
используя [simdutf](https://github.com/simdutf/simdutf). Строки "совместимых" типов преобразуются простым копированием:
|
||||
`char <-> char8_t`, `wchar_t <-> char32_t` в Linux, `wchar_t <-> char16_t` в Windows.
|
||||
- Интеграция с функциями форматирования `format` и `sprintf` (с автоматическим увеличением буфера).
|
||||
Форматирование возможно для строк `char`, `wchar_t` и строк, совместимых с ними по размеру.
|
||||
То есть под Windows это `char8_t`, `char16_t`, под Linux - `char8_t`, `char32_t` (писать свою библиотеку форматирования для всех видов
|
||||
символов не входило в мои замыслы).
|
||||
- Содержится минимальная поддержка Unicode при преобразовании `upper`, `lower` и регистро-независимом сравнении строк.
|
||||
Работает только для символов первой плоскости Unicode (до 0xFFFF), а при смене регистра не учитываются случаи, когда один code point
|
||||
может преобразовываться в несколько, то есть преобразование регистра символов соответствует `std::towupper`, `std::towlower` для unicode локали, только быстрее и может работать с любым видом символов.
|
||||
|
|
@ -55,11 +90,187 @@
|
|||
сравнения ключей по сравнению с ключами `std::string`. Поддерживается возможность регистро-независимого сравнения ключей (Ascii или
|
||||
минимальный Unicode (см. предыдущий пункт)).
|
||||
|
||||
## Строковые выражения
|
||||
Это специальные объекты, которые эффективно реализуют конкатенацию строк, с помощью `operator+`.
|
||||
Главный принцип, за счёт которого достигается эффективная работа - сколько бы операндов не входило во всё выражение,
|
||||
никаких временных (промежуточных) строк не создаётся, общая длина всего результата подсчитывается только один раз,
|
||||
один раз выделяется память под буфер символов результата, после чего символы копируются сразу в буфер результата
|
||||
на своё место. Никаких перевыделений памяти, никакого передвигания символов в различных промежуточных буферах - всё
|
||||
максимально эффективно. Благодаря возможностям шаблонов C++ и перегрузке операторов, выражение пишется максимально
|
||||
приближённо к обычному синтаксису сложения строк.
|
||||
Кроме того, есть специальные перегрузки для сложения строковых объектов и строковых литералов, строк и чисел,
|
||||
для копирования с заменой, для слияния контейнеров строк и многое другое.
|
||||
Благодаря расширяемости этой системы - возможно создание новых вариантов построения строк, развитие постоянно продолжается.
|
||||
|
||||
Все строковые объекты из `simstr` - сами являются строковыми выражениями, то есть их можно использовать в операциях конкатенации
|
||||
строковых выражений напрямую. Стандартные строки (`std::basic_string`, `std::basic_string_view`) - тоже могут служить операндами
|
||||
в операциях сложения со строковыми выражениями. Либо их можно легко преобразовать в строковое выражение, поставив перед ними
|
||||
унарный `+`.
|
||||
|
||||
## Примеры использования
|
||||
### Сложение строк с числами
|
||||
```cpp
|
||||
std::string s1 = "start ";
|
||||
int i;
|
||||
....
|
||||
// Было
|
||||
std::string str = s1 + std::to_string(i) + " end";
|
||||
// Стало
|
||||
std::string str = +s1 + i + " end";
|
||||
```
|
||||
`+s1` - преобразует `std::string` в объект - строковое выражение, для которого есть эффективная конкатенация с числами и строковыми литералами.
|
||||
|
||||
По бенчмаркам [ускорение 1.6 - 2 раза](https://orefkov.github.io/simstr/results.html#bs70109915512075798510).
|
||||
|
||||
### Сложение строк с числами в hex-формате
|
||||
```cpp
|
||||
....
|
||||
// Было
|
||||
std::string str = s1 + std::format("0x{:x}", i) + " end";
|
||||
// Стало
|
||||
std::string str = +s1 + e_hex<HexFlags::Short>(i) + " end";
|
||||
```
|
||||
Ускорение в [**9 - 14 раз!!!**](https://orefkov.github.io/simstr/results.html#bs146911715078927772520)
|
||||
|
||||
### Сложение нескольких литералов и поиск в `std::string_view`
|
||||
```cpp
|
||||
// Было так
|
||||
size_t find_pos(std::string_view src, std::string_view name) {
|
||||
// before C++26 we can not concatenate string and string_view...
|
||||
return src.find("\n- "s + std::string{name} + " -\n");
|
||||
}
|
||||
// При использовании только "strexpr.h" стало так
|
||||
size_t find_pos(ssa src, ssa name) {
|
||||
return src.find(std::string{"\n- " + name + " -\n"});
|
||||
}
|
||||
|
||||
// А при использовании полной библиотеки можно сделать так
|
||||
size_t find_pos(ssa src, ssa name) {
|
||||
// В этом варианте если результат конкатенации вмещается в 207 символов - она производится в буфере на стеке,
|
||||
// без алокации и освобождения памяти, ускорение в несколько раз. И только если результат длиннее 207 символов -
|
||||
// будет всего одна аллокация, и конкатенация будет сразу в алоцированный буфер, без перекопирования символов.
|
||||
return src.find(lstringa<200>{"\n- " + name + " -\n"});
|
||||
}
|
||||
```
|
||||
`ssa` - псевдоним для `simple_str<char>` - аналог `std::string_view`, позволяет с минимальными расходами принимать параметром функции
|
||||
любой строковый объект, который не нужно модифицировать или передавать в C-API: `std::string`, `std::string_view`, `"строковый литерал"`,
|
||||
`simple_str_nt`, `sstring`, `lstring`. Также так как он при этом является ещё и "строковым выражением", то позволяет легко
|
||||
строить конкатенации с его участием.
|
||||
|
||||
По замерам [ускорение 1.5 - 9 раз](https://orefkov.github.io/simstr/results.html#bs68116594352702954700).
|
||||
|
||||
### Сложение с условиями
|
||||
```cpp
|
||||
// Было
|
||||
std::string buildTypeName(std::string_view type_name, size_t prec, size_t scale) {
|
||||
std::string res{type_name};
|
||||
if (prec) {
|
||||
res += "(" + std::to_string(prec);
|
||||
if (scale) {
|
||||
res += "," + std::to_string(scale);
|
||||
}
|
||||
res += ")";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Стало при использовании только strexpr.h и желании использовать только стандартные строки
|
||||
std::string buildTypeName(std::string_view type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
// + превращает type_name из string_view в строковое выражение
|
||||
return +type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
// Стало при использовании только strexpr.h и simple_str строки
|
||||
std::string buildTypeName(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
// ssa уже является строковым выражением, + перед ним не нужен
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
// Стало при использовании полной библиотеки
|
||||
stringa buildTypeName(ssa type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
```
|
||||
При `prec != 0`, [ускорение 1.5 - 2.2 раза](https://orefkov.github.io/simstr/results.html#bs145290966789248325200).
|
||||
|
||||
### Сложение с заменами
|
||||
```cpp
|
||||
// Было
|
||||
// Стандартной аналога функции replace из других ЯП нет, напишем свою "в лоб".
|
||||
std::string str_replace(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
std::string result;
|
||||
for (size_t offset = 0;;) {
|
||||
size_t pos = from.find(pattern, offset);
|
||||
if (pos == std::string::npos) {
|
||||
result += from.substr(offset);
|
||||
break;
|
||||
}
|
||||
result += from.substr(offset, pos - offset);
|
||||
result += repl;
|
||||
offset = pos + pattern.length();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
return "<" + str_replace(from, pattern, repl) + ">";
|
||||
}
|
||||
// Стало - копирование с заменами
|
||||
std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||||
return "<" + e_repl(from, pattern, repl) + ">";
|
||||
}
|
||||
```
|
||||
[Ускорение от 1.5 раз и выше](https://orefkov.github.io/simstr/results.html#bs54035654251116789780) - в зависимости от содержимого строк.
|
||||
|
||||
### Разбиение строк на части, парсинг чисел
|
||||
```cpp
|
||||
// Было - разбить строку по разделителю и подсчитать сумму чисел
|
||||
int split_and_calc_total_str(std::string_view numbers, std::string_view delimiter) {
|
||||
int total = 0;
|
||||
for (size_t start = 0; start < numbers.length(); ) {
|
||||
int delim = numbers.find(delimiter, start);
|
||||
if (delim == std::string::npos) {
|
||||
delim = numbers.size();
|
||||
}
|
||||
std::string part{numbers.substr(start, delim - start)};
|
||||
total += std::strtol(part.c_str(), nullptr, 0);
|
||||
start = delim + delimiter.length();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
// Стало
|
||||
int split_and_calc_total_sim(ssa numbers, ssa delimiter) {
|
||||
int total = 0;
|
||||
for (auto splitter = numbers.splitter(delimiter); !splitter.is_done();) {
|
||||
total += splitter.next().as_int<int>();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
```
|
||||
[Ускорение в 2-3 раза](https://orefkov.github.io/simstr/results.html#bs7106975351756760120).
|
||||
|
||||
Помимо приведённых здесь отдельных примеров, можно посмотреть исходники:
|
||||
- [тестов всей библиотеки](https://github.com/orefkov/simstr/blob/main/tests/test_str.cpp)
|
||||
- [тестов только strexpr части](https://github.com/orefkov/simstr/blob/main/tests/test_expr_only.cpp)
|
||||
- [бенчмарков](https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp)
|
||||
- [утилиты подготовки html](https://github.com/orefkov/simstr/blob/main/bench/process_result.cpp) из результатов бенчмарков.
|
||||
|
||||
## Основные объекты библиотеки
|
||||
- simple_str<K> - самая простая строка (или кусок строки), иммутабельная, не владеющая, аналог `std::string_view`.
|
||||
- simple_str_nt<K> - то же самое, только заявляет, что заканчивается 0. Для работы со сторонними C-API.
|
||||
- sstring<K> - shared string, иммутабельная, владеющая, с разделяемым буфером символов, поддержка SSO.
|
||||
- lstring<K, N> - local string, мутабельная, владеющая, с задаваемым размером SSO буфера.
|
||||
Доступны при любом использовании:
|
||||
- `simple_str<K>` - самая простая строка (или кусок строки), иммутабельная, не владеющая, аналог `std::string_view`.
|
||||
- `simple_str_nt<K>` - то же самое, только заявляет, что заканчивается 0. Для работы со сторонними C-API.
|
||||
|
||||
Доступны при использовании всей библиотеки:
|
||||
- `sstring<K>` - shared string, иммутабельная, владеющая, с разделяемым буфером символов, поддержка SSO.
|
||||
- `lstring<K, N>` - local string, мутабельная, владеющая, с задаваемым размером SSO буфера.
|
||||
|
||||
При подключении только `strexpr.h` - типы `simple_str<K>` и `simple_str_nt<K>` не содержат методов для работы с UTF и Unicode.
|
||||
|
||||
## Статьи
|
||||
- [Обзор и введение](docs/overview_ru.md)
|
||||
|
|
@ -67,7 +278,14 @@
|
|||
- [Описание применяемой техники "Expression Templates"](https://habr.com/ru/articles/936468/)
|
||||
|
||||
## Использование
|
||||
`simstr` состоит из трёх заголовочных файлов и двух исходников. Можно подключать как CMake проект через `add_subdirectory` (библиотека `simstr`),
|
||||
Библиотеку можно использовать частично, просто взяв файл `"include\simstr\strexpr.h"` и включив в свои исходники
|
||||
```cpp
|
||||
#include "include\simstr\strexpr.h"
|
||||
```
|
||||
Это подключит только строковые выражения и упрощённые реализации `simple_str` и `simple_str_nt`, без функций работы с UTF и Unicode.
|
||||
|
||||
Полная же версия библиотеки `simstr` состоит из трёх заголовочных файлов и двух исходников.
|
||||
Можно подключать как CMake проект через `add_subdirectory` (библиотека `simstr`),
|
||||
можно просто включить файлы в свой проект. Для сборки также требуется [simdutf](https://github.com/simdutf/simdutf) (при использовании CMake
|
||||
скачивается автоматически).
|
||||
|
||||
|
|
@ -83,7 +301,6 @@
|
|||
более удобным.\
|
||||
Более подробно описано [здесь](for_debug/readme_ru.md).
|
||||
|
||||
|
||||
## Бенчмарки
|
||||
Бенчмарки производятся с использованием фреймворка [Google benchmark](https://github.com/google/benchmark).
|
||||
Постарался сделать замеры для наиболее типичных операций, встречающихся в обычной работе. Я проводил замеры на своём оборудовании, под
|
||||
|
|
@ -92,12 +309,7 @@ Windows и Linux (в WSL), с использованием компилятор
|
|||
размеры буферов SSO в объектах меньше.
|
||||
|
||||
- [Исходный код бенчмарков](bench/bench_str.cpp)
|
||||
- [Результаты бенчмарков](https://snegopat.ru/simstr/results.html)
|
||||
|
||||
## Примеры использования
|
||||
Пока отдельных примеров использования не подготовлено, можно посмотреть тексты [тестов](https://github.com/orefkov/simstr/blob/main/tests/test_str.cpp),
|
||||
[бенчмарков](https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp), и
|
||||
[утилиты подготовки html](https://github.com/orefkov/simstr/blob/main/bench/process_result.cpp) из результатов бенчмарков.
|
||||
- [Результаты бенчмарков](https://orefkov.github.io/simstr/results.html)
|
||||
|
||||
Также simstr используется в моих проектах:
|
||||
- [simjson](https://github.com/orefkov/simjson) - библиотека для простой работы с JSON с использованием строк simstr.
|
||||
|
|
@ -106,4 +318,4 @@ Windows и Linux (в WSL), с использованием компилятор
|
|||
|
||||
|
||||
## Сгенерированная документация
|
||||
[Находится здесь](https://snegopat.ru/simstr/docs_ru/)
|
||||
[Находится здесь](https://orefkov.github.io/simstr/docs_ru/)
|
||||
|
|
|
|||
|
|
@ -2,17 +2,25 @@
|
|||
# project specific logic here.
|
||||
#
|
||||
|
||||
add_executable(testStr test_str.cpp)
|
||||
add_executable(test_str test_str.cpp)
|
||||
add_executable(test_expr_only test_expr_only.cpp)
|
||||
|
||||
target_link_libraries(testStr simstr::simstr GTest::gtest_main)
|
||||
target_link_libraries(test_str simstr::simstr GTest::gtest_main)
|
||||
target_link_libraries(test_expr_only GTest::gtest_main)
|
||||
target_compile_features(test_str PUBLIC cxx_std_23)
|
||||
target_compile_features(test_expr_only PUBLIC cxx_std_23)
|
||||
|
||||
add_test(NAME testStr COMMAND testStr)
|
||||
add_test(NAME test_str COMMAND test_str)
|
||||
add_test(NAME test_expr_only COMMAND test_expr_only)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
set_target_properties (testStr PROPERTIES SUFFIX .html)
|
||||
target_compile_options(testStr PUBLIC -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3)
|
||||
set_target_properties (test_str PROPERTIES SUFFIX .html)
|
||||
target_compile_options(test_str PUBLIC -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3)
|
||||
set_target_properties (test_expr_only PROPERTIES SUFFIX .html)
|
||||
target_compile_options(test_expr_only PUBLIC -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3)
|
||||
if(SIMSTR_EMSCRIPTEN_MT)
|
||||
target_compile_options(testStr PUBLIC -pthread)
|
||||
target_compile_options(test_str PUBLIC -pthread)
|
||||
target_compile_options(test_expr_only PUBLIC -pthread)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency-1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sENVIRONMENT=web,worker")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,239 @@
|
|||
#include "../include/simstr/strexpr.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <list>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace simstr::tests {
|
||||
|
||||
TEST(StrExpr, Empty) {
|
||||
std::string testa = eea;
|
||||
EXPECT_EQ(testa, "");
|
||||
|
||||
std::u8string testb = eeb;
|
||||
EXPECT_EQ(testb, u8"");
|
||||
|
||||
std::u16string testu = eeu;
|
||||
EXPECT_EQ(testu, u"");
|
||||
|
||||
std::u32string testuu = eeuu;
|
||||
EXPECT_EQ(testuu, U"");
|
||||
|
||||
std::wstring testw = eew;
|
||||
EXPECT_EQ(testw, L"");
|
||||
}
|
||||
|
||||
TEST(StrExpr, OpPlusChar) {
|
||||
std::string testa = "test"_ss + 'a';
|
||||
EXPECT_EQ(testa, "testa");
|
||||
testa += +testa + u8'b';
|
||||
EXPECT_EQ(testa, "testatestab");
|
||||
|
||||
std::u8string testb = u8"test"_ss + u8'a';
|
||||
EXPECT_EQ(testb, u8"testa");
|
||||
#ifdef _WIN32
|
||||
std::wstring testw = L"test"_ss + u'a' + L'b';
|
||||
EXPECT_EQ(testw, L"testab");
|
||||
|
||||
std::u16string testu = +u"test"sv + L'a';
|
||||
EXPECT_EQ(testu, u"testa");
|
||||
#else
|
||||
std::wstring testw = L"test"_ss + U'a' + U'b';
|
||||
EXPECT_EQ(testw, L"testab");
|
||||
|
||||
std::u32string testu = U"test"_ss + L'a';
|
||||
EXPECT_EQ(testu, U"testa");
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(StrExpr, Spaces) {
|
||||
std::string testa = "abc" + e_spca<10>() + "cde";
|
||||
EXPECT_EQ(testa, "abc cde");
|
||||
|
||||
std::u16string testu = u"abc" + e_c(10, u'_') + u"cde";
|
||||
EXPECT_EQ(testu, u"abc__________cde");
|
||||
}
|
||||
|
||||
TEST(StrExpr, Repeat) {
|
||||
std::string testa = "abc";
|
||||
testa = e_repeat(+testa + " " + 10 + "s.", 3);
|
||||
EXPECT_EQ(testa, "abc 10s.abc 10s.abc 10s.");
|
||||
std::wstring testw = L"abc";
|
||||
testw += L" " + e_repeat(+testw + L" " + 10 + L"s.", 3);
|
||||
EXPECT_EQ(testw, L"abc abc 10s.abc 10s.abc 10s.");
|
||||
}
|
||||
|
||||
TEST(StrExpr, OpPlusDifferentTypes) {
|
||||
std::string testa = "test"_ss + u8"test";
|
||||
EXPECT_EQ(testa, "testtest");
|
||||
|
||||
std::u8string testb = "test"_ss + u8"test";
|
||||
EXPECT_EQ(testb, u8"testtest");
|
||||
#ifdef _WIN32
|
||||
std::wstring testw = L"test"_ss + u"test";
|
||||
EXPECT_EQ(testw, L"testtest");
|
||||
|
||||
std::u16string testu = +u"test"sv + L"test";
|
||||
EXPECT_EQ(testu, u"testtest");
|
||||
#else
|
||||
std::wstring testw = L"test"_ss + U"test";
|
||||
EXPECT_EQ(testw, L"testtest");
|
||||
|
||||
std::u32string testu = U"test"_ss + L"test";
|
||||
EXPECT_EQ(testu, U"testtest");
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(StrExpr, AddNumber) {
|
||||
std::string testa = "test"_ss + 10;
|
||||
EXPECT_EQ(testa, "test10");
|
||||
|
||||
std::u8string testb = u8"test"_ss + 10;
|
||||
EXPECT_EQ(testb, u8"test10");
|
||||
|
||||
std::u16string testu = u"test"_ss + 10;
|
||||
EXPECT_EQ(testu, u"test10");
|
||||
|
||||
std::u32string testuu = U"test"_ss + 10;
|
||||
EXPECT_EQ(testuu, U"test10");
|
||||
|
||||
std::wstring testw = L"test"_ss + 10;
|
||||
EXPECT_EQ(testw, L"test10");
|
||||
}
|
||||
TEST(StrExpr, Choice) {
|
||||
std::string testa = "t = " + e_choice(true, "test", "t") + " " + 10 + e_if(true, " from "_ss + 20);
|
||||
EXPECT_EQ(testa, "t = test 10 from 20");
|
||||
testa = "t = " + e_choice(false, "test", "t") + " " + 10 + e_if(false, " from "_ss + 20);
|
||||
EXPECT_EQ(testa, "t = t 10");
|
||||
}
|
||||
|
||||
TEST(StrExpr, Fill) {
|
||||
std::string testa = "t = " + e_fill_left(+"test"s, 10);
|
||||
EXPECT_EQ(testa, "t = test");
|
||||
testa = "t = " + e_fill_right(+"test"s, 10, '-');
|
||||
EXPECT_EQ(testa, "t = test------");
|
||||
|
||||
std::u16string testu = u"t = " + e_fill_left(e_repl(u"test"sv, u"t", u"--"), 10);
|
||||
EXPECT_EQ(testu, u"t = --es--");
|
||||
}
|
||||
|
||||
TEST(StrExpr, Join) {
|
||||
std::vector<ssa> lst = {"abc", "def", "ghi"};
|
||||
std::string testa = "/" + e_join(lst, "-") + "/";
|
||||
EXPECT_EQ(testa, "/abc-def-ghi/");
|
||||
|
||||
std::vector<std::u16string_view> ulst = {u"abc", u"def", u"ghi"};
|
||||
std::u16string testu = u"/" + e_join(ulst, u"-") + u"/";
|
||||
EXPECT_EQ(testu, u"/abc-def-ghi/");
|
||||
|
||||
std::list<std::wstring> wlst = {L"abc", L"def", L"ghi"};
|
||||
std::wstring testw = L"/" + e_join(wlst, L"-") + L"/" + e_join(wlst, L"++");
|
||||
EXPECT_EQ(testw, L"/abc-def-ghi/abc++def++ghi");
|
||||
}
|
||||
|
||||
TEST(StrExpr, Replace) {
|
||||
std::string testa = e_repl("test"_ss, "t"sv, "-|-"s) + 10;
|
||||
EXPECT_EQ(testa, "-|-es-|-10");
|
||||
testa = e_repl("aaaaaaaaaaaaaaaa"_ss, "a", "bb");
|
||||
EXPECT_EQ(testa, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
|
||||
testa = e_repl("aaaaaaaaaaaaaaaa"_ss, "a", "") + "-";
|
||||
EXPECT_EQ(testa, "-");
|
||||
|
||||
testa = e_repl("aaaaaaaaaaaaaaaaaad"_ss, "a", "bb");
|
||||
EXPECT_EQ(testa, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbd");
|
||||
testa = e_repl(testa, "bb", "a");
|
||||
EXPECT_EQ(testa, "aaaaaaaaaaaaaaaaaad");
|
||||
|
||||
std::u8string testb = e_repl(u8"test"sv, u8"t", u8"-|-") + 10;
|
||||
EXPECT_EQ(testb, u8"-|-es-|-10");
|
||||
|
||||
std::u16string testu = e_repl(u"test"sv, u"t", u"-|-") + 10;
|
||||
EXPECT_EQ(testu, u"-|-es-|-10");
|
||||
|
||||
std::u32string testuu = e_repl(U"test"sv, U"t", U"-|-") + 10;
|
||||
EXPECT_EQ(testuu, U"-|-es-|-10");
|
||||
|
||||
std::wstring testw = e_repl(L"test"s, L"t", L"-|-") + 10;
|
||||
EXPECT_EQ(testw, L"-|-es-|-10");
|
||||
}
|
||||
|
||||
size_t find_pos_str(const std::string& src, std::string_view name) {
|
||||
return src.find("\n- " + std::string(name) + " -\n");
|
||||
}
|
||||
|
||||
size_t find_pos_exp(const std::string& src, ssa name) {
|
||||
return src.find("\n- " + name + " -\n");
|
||||
}
|
||||
|
||||
TEST(StrExpr, FindConcatThree) {
|
||||
std::string src = "sdfsdf\n- testtest -\nsfrgdgfsg";
|
||||
EXPECT_EQ(find_pos_str(src, "testtest"sv), 6);
|
||||
EXPECT_EQ(find_pos_exp(src, "testtest"sv), 6);
|
||||
}
|
||||
|
||||
std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
|
||||
std::string res{type_name};
|
||||
if (prec) {
|
||||
res += "(" + std::to_string(prec);
|
||||
if (scale) {
|
||||
res += "," + std::to_string(scale);
|
||||
}
|
||||
res += ")";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string buildTypeNameExp(std::string_view type_name, size_t prec, size_t scale) {
|
||||
if (prec) {
|
||||
return type_name + "("_ss + prec + e_if(scale, ","_ss + scale) + ")";
|
||||
}
|
||||
return std::string{type_name};
|
||||
}
|
||||
|
||||
TEST(StrExpr, MultiConcat) {
|
||||
EXPECT_EQ(buildTypeNameStr("integer", 0, 0), "integer");
|
||||
EXPECT_EQ(buildTypeNameStr("numeric", 10, 2), "numeric(10,2)");
|
||||
EXPECT_EQ(buildTypeNameExp("integer", 0, 0), "integer");
|
||||
EXPECT_EQ(buildTypeNameExp("numeric", 10, 2), "numeric(10,2)");
|
||||
}
|
||||
|
||||
int split_and_calc_total_str(std::string_view numbers, std::string_view delimiter) {
|
||||
int total = 0;
|
||||
for (size_t start = 0; start < numbers.length(); ) {
|
||||
int delim = numbers.find(delimiter, start);
|
||||
if (delim == std::string::npos) {
|
||||
delim = numbers.size();
|
||||
}
|
||||
std::string part{numbers.substr(start, delim - start)};
|
||||
total += std::strtol(part.c_str(), nullptr, 0);
|
||||
start = delim + delimiter.length();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
int split_and_calc_total_sim(ssa numbers, ssa delimiter) {
|
||||
int total = 0;
|
||||
for (auto splitter = numbers.splitter(delimiter); !splitter.is_done();) {
|
||||
total += splitter.next().as_int<int>();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
TEST(StrExpr, SplitCalcTotal) {
|
||||
const char NUMBER_LIST[] = "1-!- 2-!- 3-!- 4 -!- 5-!- 6 -!- 7-!- -8-!- 0xaF-!- 15-!- 010"; // 218
|
||||
const char delim[] = "-!-";
|
||||
EXPECT_EQ(split_and_calc_total_str(NUMBER_LIST, delim), 218);
|
||||
EXPECT_EQ(split_and_calc_total_sim(NUMBER_LIST, delim), 218);
|
||||
}
|
||||
|
||||
TEST(StrExpr, StdToSimplestr) {
|
||||
std::string test = " sdfsg ";
|
||||
std::string_view res = ssa{test}.trimmed();
|
||||
EXPECT_EQ(res, "sdfsg");
|
||||
|
||||
size_t fnd = test.find(" " + std::string{res});
|
||||
EXPECT_EQ(fnd, 2);
|
||||
}
|
||||
|
||||
} // namespace simstr::tests
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
#include <simstr/sstring.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace simstr::tests {
|
||||
using namespace std::literals;
|
||||
|
||||
namespace simstr::tests {
|
||||
|
||||
class Tstringa: public stringa {
|
||||
public:
|
||||
using stringa::stringa;
|
||||
|
|
@ -563,7 +564,7 @@ TEST(SimStr, ChangeCase) {
|
|||
TEST(SimStr, Replace) {
|
||||
EXPECT_EQ(ssa{"testing"}.replaced<stringa>("t", "--"), "--es--ing");
|
||||
EXPECT_EQ(ssa{"testing"}.replaced<stringa>("t", ""), "esing");
|
||||
EXPECT_EQ(stringa{ssa{"testing"}.replace_init("t", "--")}, "--es--ing");
|
||||
EXPECT_EQ(stringa{e_repl(ssa{"testing"}, "t", "--")}, "--es--ing");
|
||||
}
|
||||
|
||||
TEST(SimStr, Trim) {
|
||||
|
|
@ -1279,6 +1280,39 @@ TEST(SimStr, LStrFormat) {
|
|||
text.format(L"{}", L"tested");
|
||||
EXPECT_EQ(text, L"tested");
|
||||
}
|
||||
#ifdef _WIN32
|
||||
{
|
||||
// char16_t в Windows совместим по размеру с wchar_t, поэтому для его форматирования можно использовать
|
||||
// L"format_string", и передавать char16_t строковые объекты
|
||||
// char16_t on Windows is compatible in size with wchar_t, so you can use L"format_string" to format it
|
||||
// and pass char16_t string objects
|
||||
lstringu<2> text;
|
||||
text.format(L"{}{}", 'a', 'b');
|
||||
EXPECT_EQ(text, u"ab");
|
||||
text.format(L"{}{}", L"tested", text);
|
||||
EXPECT_EQ(text, u"testedab");
|
||||
|
||||
lstringw<10> tew;
|
||||
tew.format(L"-{}-", text);
|
||||
EXPECT_EQ(tew, L"-testedab-");
|
||||
}
|
||||
#else
|
||||
{
|
||||
// char32_t в Windows совместим по размеру с wchar_t, поэтому для его форматирования можно использовать
|
||||
// L"format_string", и передавать char32_t строковые объекты
|
||||
// char32_t on Windows is compatible in size with wchar_t, so you can use L"format_string" to format it
|
||||
// and pass char32_t string objects
|
||||
lstringuu<2> text;
|
||||
text.format(L"{}{}", 'a', 'b');
|
||||
EXPECT_EQ(text, U"ab");
|
||||
text.format(L"{}{}", L"tested", text);
|
||||
EXPECT_EQ(text, U"testedab");
|
||||
|
||||
lstringw<10> tew;
|
||||
tew.format(L"-{}-", text);
|
||||
EXPECT_EQ(tew, L"-testedab-");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
lstringa<40> text = "tested";
|
||||
text.format_from(4, "{}{}", 'a', 'b');
|
||||
|
|
@ -1703,6 +1737,10 @@ TEST(SimStr, StdStringExpr) {
|
|||
lstringa<20> res = eea + "test"s;
|
||||
EXPECT_EQ(res, "test");
|
||||
}
|
||||
{
|
||||
lstringa<20> res = +"test"s;
|
||||
EXPECT_EQ(res, "test");
|
||||
}
|
||||
{
|
||||
lstringa<20> res = "test"s + eea;
|
||||
EXPECT_EQ(res, "test");
|
||||
|
|
@ -1711,55 +1749,20 @@ TEST(SimStr, StdStringExpr) {
|
|||
lstringa<20> res = eea + "test"sv;
|
||||
EXPECT_EQ(res, "test");
|
||||
}
|
||||
{
|
||||
lstringa<20> res = +"test"sv;
|
||||
EXPECT_EQ(res, "test");
|
||||
}
|
||||
{
|
||||
lstringu<20> res = +u"test"sv;
|
||||
EXPECT_EQ(res, u"test");
|
||||
}
|
||||
{
|
||||
lstringa<20> res = "test"sv + eea;
|
||||
EXPECT_EQ(res, "test");
|
||||
}
|
||||
}
|
||||
|
||||
static std::string checker_str = "str";
|
||||
static std::string_view checker_view;
|
||||
|
||||
static std::string get_string_val();
|
||||
static std::string& get_string_ref(){return checker_str;}
|
||||
static const std::string get_string_cval();
|
||||
static const std::string& get_string_cref(){return checker_str;}
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(std::string{""});}
|
||||
char check_lvalue_str();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(""s);}
|
||||
char check_lvalue_str();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(get_string_val());}
|
||||
char check_lvalue_str();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(get_string_cval());}
|
||||
char check_lvalue_str();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(checker_str);}
|
||||
int check_lvalue_str();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(std::string_view{""});}
|
||||
char check_lvalue_view();
|
||||
|
||||
template<typename K>
|
||||
requires requires{new simple_str<K>(checker_view);}
|
||||
int check_lvalue_view();
|
||||
|
||||
TEST(SimStr, InitFromLValueStdStrings) {
|
||||
EXPECT_EQ(sizeof(check_lvalue_str<u8s>()), sizeof(int));
|
||||
EXPECT_EQ(sizeof(check_lvalue_view<u8s>()), sizeof(int));
|
||||
EXPECT_EQ(ssa(get_string_ref()), "str");
|
||||
EXPECT_EQ(ssa(get_string_cref()), "str");
|
||||
}
|
||||
|
||||
TEST(SimStr, HashStrMapAt) {
|
||||
hashStrMapA<int> test = {
|
||||
{"Test"_h, 1}
|
||||
|
|
@ -1773,6 +1776,7 @@ TEST(SimStr, ExprRepeat) {
|
|||
EXPECT_EQ(stringa{e_repeat("aa", 3)}, "aaaaaa");
|
||||
int t = 1;
|
||||
EXPECT_EQ(lstringa<40>{e_repeat("aa"_ss + t + "_", 3)}, "aa1_aa1_aa1_");
|
||||
EXPECT_EQ(std::string{e_repeat("aa"_ss + t + "_", 3)}, "aa1_aa1_aa1_");
|
||||
}
|
||||
|
||||
TEST(SimStr, Constexpr) {
|
||||
|
|
@ -1782,6 +1786,182 @@ TEST(SimStr, Constexpr) {
|
|||
static_assert(aa == "asd");
|
||||
static_assert(aa.length() == 3);
|
||||
constexpr stringa bb = "";
|
||||
constexpr int k = "123"_ss.to_int<int>().value;
|
||||
static_assert(k == 123);
|
||||
}
|
||||
|
||||
TEST(SimStr, StrExpToStdString) {
|
||||
std::basic_string<u8s, std::char_traits<u8s>, std::pmr::polymorphic_allocator<u8s>> test = "count = "_ss + 10 + " times";
|
||||
EXPECT_EQ(test, "count = 10 times");
|
||||
|
||||
test = "aaa"_ss;
|
||||
EXPECT_EQ(test, "aaa");
|
||||
EXPECT_EQ("aaa"_ss.to_sv(), "aaa");
|
||||
|
||||
std::string auto_utf = e_utf<u8s>(u"Привет"_ss);
|
||||
EXPECT_EQ(auto_utf, "Привет");
|
||||
auto_utf = e_utf<u8s>(L"Досвидания"_ss);
|
||||
EXPECT_EQ(auto_utf, "Досвидания");
|
||||
|
||||
std::string res = +"test "s + 10 + e_if(true, " times");
|
||||
EXPECT_EQ(res, "test 10 times");
|
||||
|
||||
res = +"test "sv + 10 + e_if(true, " times");
|
||||
EXPECT_EQ(res, "test 10 times");
|
||||
}
|
||||
std::string make_text(const std::string& text, int count, std::string_view what, std::string_view what_p = ""sv) {
|
||||
return +text + " " + count + " " + e_choice(what_p.empty(), what + e_if(count > 1, "s"), e_choice(count > 1, +what_p, +what));
|
||||
}
|
||||
|
||||
std::string make_answer(const std::string& text, int count, std::string_view what, std::string_view what_p = ""sv) {
|
||||
return "Answer is: " + +text + " " + count + " " + e_choice(what_p.empty(), what + e_if(count > 1, "s"), e_choice(count > 1, +what_p, +what));
|
||||
}
|
||||
|
||||
TEST(SimStr, StrPrintfU8) {
|
||||
stringb tt = u8"asdf";
|
||||
stringa tr = tt;
|
||||
EXPECT_EQ(tr, "asdf");
|
||||
tt = tr;
|
||||
EXPECT_EQ(tt, u8"asdf");
|
||||
|
||||
lstringb<100> res;
|
||||
res.printf(u8"asd %i", 10);
|
||||
EXPECT_EQ(res, u8"asd 10");
|
||||
|
||||
std::u8string std_bstr = u8"def";
|
||||
std::vector<ssa> ll = {"qwe", "rty"};
|
||||
|
||||
stringb bstring = eea + "abc" + u8"def" + 10 + e_spca<3>() + e_join(ll, "-");
|
||||
EXPECT_EQ(bstring, u8"abcdef10 qwe-rty");
|
||||
|
||||
stringa check_choice = e_choice(true, eea + 10, u8"aaa");
|
||||
EXPECT_EQ(check_choice, "10");
|
||||
|
||||
check_choice = e_choice(false, eea + 10, u8"aaa");
|
||||
EXPECT_EQ(check_choice, "aaa");
|
||||
|
||||
check_choice = e_choice(true, "aaa", u8"aaa");
|
||||
EXPECT_EQ(check_choice, "aaa");
|
||||
|
||||
check_choice = eea + e_if(true, u8"aaa");
|
||||
EXPECT_EQ(check_choice, "aaa");
|
||||
|
||||
check_choice = eeb + e_if(true, "aaa");
|
||||
EXPECT_EQ(check_choice, "aaa");
|
||||
std::wstring wstr = L"test"sv +
|
||||
#if WIN32
|
||||
u"test"_ss
|
||||
#else
|
||||
U"test"_ss
|
||||
#endif
|
||||
;
|
||||
EXPECT_EQ(wstr, L"testtest");
|
||||
|
||||
EXPECT_EQ(make_text("got"s, 10, "apple"sv), "got 10 apples");
|
||||
EXPECT_EQ(make_answer("got"s, 10, "aloe"sv, "aloe"sv), "Answer is: got 10 aloe");
|
||||
}
|
||||
|
||||
TEST(SimStr, ExprReal) {
|
||||
stringa a = e_num<u8s>(1.1);
|
||||
EXPECT_EQ(a, "1.1");
|
||||
|
||||
stringb b = e_num<ubs>(1.1);
|
||||
EXPECT_EQ(b, u8"1.1");
|
||||
|
||||
stringuu uu = e_num<u32s>(1.1);
|
||||
EXPECT_EQ(uu, U"1.1");
|
||||
|
||||
stringu u = e_num<u16s>(1.1);
|
||||
EXPECT_EQ(u, u"1.1");
|
||||
|
||||
stringw w = e_num<uws>(1.1);
|
||||
EXPECT_EQ(w, L"1.1");
|
||||
}
|
||||
|
||||
TEST(SimStr, StrRepl) {
|
||||
std::string r = e_repl("test"s, "t", "-t-");
|
||||
EXPECT_EQ(r, "-t-es-t-");
|
||||
|
||||
r = e_repl("test"sv, "t", "-t-");
|
||||
EXPECT_EQ(r, "-t-es-t-");
|
||||
|
||||
r = e_repl("test"sv, "t"s, "-t-");
|
||||
EXPECT_EQ(r, "-t-es-t-");
|
||||
|
||||
r = e_repl("test"sv, "t", "-t-"sv);
|
||||
EXPECT_EQ(r, "-t-es-t-");
|
||||
|
||||
r = e_repl("test"s, "t"sv, "-t-"s);
|
||||
EXPECT_EQ(r, "-t-es-t-");
|
||||
|
||||
stringa a = e_repl("test"_ss, "t", "-t-");
|
||||
EXPECT_EQ(a, "-t-es-t-");
|
||||
|
||||
a = e_repl("test"_ss, "t"_ss, "-t-");
|
||||
EXPECT_EQ(a, "-t-es-t-");
|
||||
|
||||
a = e_repl("test"_ss, "t", "-t-"_ss);
|
||||
EXPECT_EQ(a, "-t-es-t-");
|
||||
|
||||
a = e_repl("test"_ss, "t"_ss, "-t-"_ss);
|
||||
EXPECT_EQ(a, "-t-es-t-");
|
||||
}
|
||||
|
||||
TEST(SimStr, HexEpr) {
|
||||
stringa hexa = expr_hex<u8s, unsigned, true, true, true>{0xabcd0102};
|
||||
EXPECT_EQ(hexa, "0xABCD0102");
|
||||
|
||||
stringu hexu = expr_hex<u16s, unsigned, true, true, true>{0xabcd0102};
|
||||
EXPECT_EQ(hexu, u"0xABCD0102");
|
||||
|
||||
stringuu hexuu = expr_hex<u32s, unsigned, true, true, true>{0xabcd0102};
|
||||
EXPECT_EQ(hexuu, U"0xABCD0102");
|
||||
|
||||
stringb hexb = expr_hex<ubs, unsigned, true, true, true>{0xcd0102};
|
||||
EXPECT_EQ(hexb, u8"0x00CD0102");
|
||||
|
||||
hexa = expr_hex<u8s, uint64_t, true, false, false>{0xabcd0102};
|
||||
EXPECT_EQ(hexa, "00000000abcd0102");
|
||||
|
||||
hexa = expr_hex<u8s, uint32_t, false, false, false>{0};
|
||||
EXPECT_EQ(hexa, "0");
|
||||
hexa = expr_hex<u8s, uint32_t, false, false, true>{0};
|
||||
EXPECT_EQ(hexa, "0x0");
|
||||
hexa = expr_hex<u8s, uint32_t, true, false, true>{0};
|
||||
EXPECT_EQ(hexa, "0x00000000");
|
||||
|
||||
std::string text = +"val = "sv + e_hex(10u);
|
||||
EXPECT_EQ(text, "val = 0x0000000A");
|
||||
|
||||
stringu textu = u"val = 0X"_ss + e_hex<HexFlags::No0x | HexFlags::Short | HexFlags::Lcase>(0x12Au);
|
||||
EXPECT_EQ(textu, u"val = 0X12a");
|
||||
|
||||
std::u32string textuu = +U"val = 0X"sv + e_hex<HexFlags::No0x | HexFlags::Short>(0x12Au);
|
||||
EXPECT_EQ(textuu, U"val = 0X12A");
|
||||
|
||||
text = +"ptr = "sv + (const void*)0xdeadbeefcafe01;
|
||||
EXPECT_EQ(text, "ptr = 0x00DEADBEEFCAFE01");
|
||||
|
||||
const char* ptr = (const char*)0xdeadbeefcafe01;
|
||||
std::u16string utext = ptr + +u" freed"sv;
|
||||
EXPECT_EQ(utext, u"0x00DEADBEEFCAFE01 freed");
|
||||
}
|
||||
|
||||
TEST(SimStr, EFill) {
|
||||
int k = 10;
|
||||
stringa test = "<" + e_fill_left("t="_ss + k, 10, '_');
|
||||
EXPECT_EQ(test, "<______t=10");
|
||||
test = e_fill_right("t="_ss + k, 10, '_') + ">";
|
||||
EXPECT_EQ(test, "t=10______>");
|
||||
}
|
||||
|
||||
} // namespace simstr::tests
|
||||
|
||||
TEST(SimStr, StrNoNamespace) {
|
||||
std::string str = "test";
|
||||
std::string test = +str + " = " + 10;
|
||||
EXPECT_EQ(test, "test = 10");
|
||||
|
||||
std::u16string textu = +u"val = 0X"sv + simstr::e_hex<simstr::HexFlags::No0x | simstr::HexFlags::Short | simstr::HexFlags::Lcase>(0x12Au);
|
||||
EXPECT_EQ(textu, u"val = 0X12a");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue