2025-04-05 14:21:11 +00:00
< html >
< head >
< meta charset = "UTF-8" / >
< link href = "results.css" rel = "stylesheet" / >
< title > SimStr benchmarks results< / title >
< link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" > < / script >
< script src = "https://cdn.jsdelivr.net/npm/chart.js" > < / script >
< script >
let bench_sets = {};
let activeBuilder = buildTestsByPlatformsBar;
let buildAsLine = {
"Copy not literal Str with N symbols": "Length of the copied string",
"Replace All Str To Longer Size": "Length of the string to be replaced",
"Replace All Str To Same Size": "Length of the string to be replaced"
};
function hl() {
document.querySelectorAll('.tooltiptext.code').forEach((el) => {
hljs.highlightElement(el);
});
}
function addBarChart(id, data) {
let canvas = document.getElementById('chart' + id);
new Chart(canvas, {
type: 'bar',
data: data,
options: {
scales: {
y: {
beginAtZero: true
},
x: {
title: {
text: "Time (ns)",
display: true
}
}
},
indexAxis: 'y',
plugins: {
legend: {
position: 'right',
labels: {
font: {
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
}
}
}
}
}
});
}
function platformChecked(idx) {
return document.getElementById('pl' + idx).checked;
}
function buildPlatformsByTestsBar(bsName) {
if (buildAsLine[bsName]) {
buildPlatformsByTestsLine(bsName, buildAsLine[bsName]);
return;
}
let data = { labels: [], datasets: [] };
for (const i in platform_names) {
if (platformChecked(i))
data.datasets.push({ label: platform_names[i], data: [], borderWidth: 1 });
}
let bs = bench_sets[bsName];
for (const test of bs.tests) {
data.labels.push(test.name);
let ds = 0;
for (const i in test.data) {
if (platformChecked(i)) {
data.datasets[ds++].data.push(test.data[i]);
}
}
}
addBarChart(bs.id, data);
}
function buildTestsByPlatformsBar(bsName) {
if (buildAsLine[bsName], buildAsLine[bsName]) {
buildTestsByPlatformsLine(bsName, buildAsLine[bsName]);
return;
}
let data = { labels: [], datasets: [] };
let bs = bench_sets[bsName];
for (const test of bs.tests) {
data.datasets.push({ label: test.name, data: [], borderWidth: 1 });
}
for (const i in platform_names) {
if (platformChecked(i)) {
data.labels.push(platform_names[i]);
for (const j in bs.tests) {
data.datasets[j].data.push(bs.tests[j].data[i]);
}
}
}
addBarChart(bs.id, data);
}
function buildCanvas(plCount) {
document.querySelectorAll("canvas.bench_chart").forEach(e => e.remove());
for (var bs_name in bench_sets) {
let bs = bench_sets[bs_name];
if (plCount) {
let canvas = document.createElement('canvas');
canvas.id = "chart" + bs.id;
canvas.classList.add('bench_chart');
let h = 20 * plCount * bs.tests.length;
canvas.style.width = "100%";
canvas.style.height = h + "px";
canvas.height = h * devicePixelRatio;
document.getElementById(bs.id).after(canvas);
}
}
}
function addLineChart(canvas, data, title, scaleTitle) {
new Chart(canvas, {
type: 'line',
data: data,
options: {
scales: {
y: {
beginAtZero: true,
title: {
text: scaleTitle,
display: true
}
},
x: {
title: {
text: "Time (ns)",
display: true
}
}
},
indexAxis: 'y',
plugins: {
title: {
display: true,
text: title,
},
legend: {
position: 'right',
labels: {
font: {
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
}
}
}
}
}
});
}
function buildTestsByPlatformsLineOne(bs, canvas, plIdx, scaleTitle) {
let data = { datasets: [] };
let prevTest = '';
let curData = undefined;
for (const test of bs.tests) {
let m = test.name.match(/(.+)[\/\|](\d+)$/);
if (m[1] != prevTest) {
prevTest = m[1];
curData = { label: prevTest, data: [], borderWidth: 1 };
data.datasets.push(curData);
}
curData.data.push([test.data[plIdx], m[2]]);
}
addLineChart(canvas, data, platform_names[plIdx], scaleTitle);
}
function buildTestsByPlatformsLine(bsName, scaleTitle) {
let bs = bench_sets[bsName];
let canvas = document.getElementById('chart' + bs.id);
let after = null;
for (const i in platform_names) {
if (platformChecked(i)) {
if (!canvas) {
canvas = document.createElement('canvas');
canvas.classList.add('bench_chart');
canvas.style.width = "100%";
after.after(canvas);
}
canvas.style.height = "300px";
canvas.height = 300 * devicePixelRatio;
buildTestsByPlatformsLineOne(bs, canvas, i, scaleTitle);
after = canvas;
canvas = null;
}
}
}
function buildPlatformsByTestsLineOne(bs, canvas, after, testData, title, scaleTitle) {
let data = { datasets: [] };
for (const i in platform_names) {
if (platformChecked(i)) {
ds = {label: platform_names[i], data: []};
for (const test of testData) {
ds.data.push([test.data[i], test.count]);
}
data.datasets.push(ds);
}
}
if (!canvas) {
canvas = document.createElement('canvas');
canvas.classList.add('bench_chart');
canvas.style.width = "100%";
after.after(canvas);
}
canvas.style.height = "300px";
canvas.height = 300 * devicePixelRatio;
addLineChart(canvas, data, title, scaleTitle);
return canvas;
}
function buildPlatformsByTestsLine(bsName, scaleTitle) {
let bs = bench_sets[bsName];
let canvas = document.getElementById('chart' + bs.id);
let after = null;
let data = [];
let prevTest = '';
for (const test of bs.tests) {
let m = test.name.match(/(.+)[\/\|](\d+)$/);
if (m[1] != prevTest) {
if (data.length) {
after = buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
canvas = null;
}
prevTest = m[1];
data = [];
}
data.push({count: m[2], data: test.data});
}
if (data.length) {
buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
}
}
function buildCharts() {
let plCount = 0;
for (const i in platform_names) {
if (platformChecked(i))
plCount++;
}
buildCanvas(plCount);
for (var bs_name in bench_sets) {
activeBuilder(bs_name);
}
}
function switchGrouping() {
activeBuilder = document.getElementById('gbp').checked ? buildTestsByPlatformsBar : buildPlatformsByTestsBar;
buildCharts();
}
document.addEventListener('DOMContentLoaded', (event) => {
if (!hljs) {
let scriptTag = document.createElement('script');
scriptTag.src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js";
scriptTag.onload = hl;
scriptTag.onreadystatechange = hl;
document.body.appendChild(scriptTag);
} else {
hl();
}
if (!Chart) {
let scriptTag = document.createElement('script');
scriptTag.src = "https://cdn.jsdelivr.net/npm/chart.js";
scriptTag.onload = buildCharts;
scriptTag.onreadystatechange = buildCharts;
document.body.appendChild(scriptTag);
} else {
buildCharts();
}
});
< / script >
2026-02-03 07:38:21 +00:00
< / head > < body > < div class = "header" > < h2 > simstr benchmarks results< / h2 >
< div style = "font-size:16pt;margin:20px;text-align:center" > < a href = "https://github.com/orefkov/simstr" > simstr< / a > is a powerful and convenient library for productive work with strings in C++.< / div >
2025-04-05 14:21:11 +00:00
< span > All times in ns.< / span >
< span > < a href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp" > Source for benchmarks< / a > < / span >
< div > Group tests by platforms in charts: < input type = "checkbox" id = "gbp" checked onchange = "switchGrouping()" / > < / div > < div class = "test_platforms" > < h3 > Test configurations:< / h3 > < ul >
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-02-15 14:13:54 +00:00
Load Average: 0.00, 0.00, 0.00
2026-01-21 11:59:17 +00:00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl0" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-02-15 14:13:54 +00:00
Load Average: 0.32, 0.33, 0.38
2026-01-21 11:59:17 +00:00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl1" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, Clang-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl2" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, MSVC-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl3" checked onchange = "buildCharts()" / > < / li >
2026-02-08 11:17:03 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / span > < span class = "tooltip" > 32 X 2513.96 MHz CPU s< span class = "tooltiptext" > Chrome/143.0.0.0 webasm< / span > < / span > Include in charts: < input type = "checkbox" id = "pl4" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< / ul > < / div > < / div >
2026-02-08 11:17:03 +00:00
< script > const platform _names = [ 'Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21' , 'Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13' , 'Xeon E5-2682 v4, Windows 10, Clang-19' , 'Xeon E5-2682 v4, Windows 10, MSVC-19' , 'Xeon E5-2682 v4, WASM Chrome 143, Clang-21' ] ; < / script >
2025-04-05 14:21:11 +00:00
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs1" > < h4 > < a id = "bs15359472366966513900" href = "#bs15359472366966513900" > #< / a > Concatenate email< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L94" > Concat email std::format< / a > < span class = "tooltiptext code" > std::string email_concat_format(std::string_view name, std::string_view domain, std::string_view tld) {
2026-02-14 10:09:54 +00:00
return std::format(" {}@{}.{}" , name, domain, tld);
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 170< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 205< / td > < td class = "benchmarkresult" > 253< / td > < td class = "benchmarkresult" > 993< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L109" > Concat email std::stringstream< / a > < span class = "tooltiptext code" > std::string email_concat_stream(std::string_view name, std::string_view domain, std::string_view tld) {
2026-02-14 10:09:54 +00:00
std::stringstream s;
s < < name < < " @" < < domain < < " ." < < tld;
return s.str();
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 325< / td > < td class = "benchmarkresult" > 324< / td > < td class = "benchmarkresult" > 833< / td > < td class = "benchmarkresult" > 946< / td > < td class = "benchmarkresult" > 2513< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L60" > Concat email stringzilla append< / a > < span class = "tooltiptext code" > sz::string email_concat_stringzilla_app(sz::string name, sz::string_view domain, sz::string_view tld) {
2026-02-14 10:09:54 +00:00
return name.append(" @" ).append(domain).append(" ." ).append(tld);
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 142< / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 267< / td > < td class = "benchmarkresult" > 289< / td > < td class = "benchmarkresult" > 574< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L77" > Concat email stringzilla concat< / a > < span class = "tooltiptext code" > sz::string email_concat_stringzilla_exp(sz::string name, sz::string_view domain, sz::string_view tld) {
2026-02-14 10:09:54 +00:00
return sz::string{name | sz::string_view{" @" } | domain | sz::string_view{" ." } | tld};
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В stringzilla тоже есть конкатенация строковыми выражениями, но не
так удобна и развита, как в simstr.
Stringzilla also has concatenation by expression templates,
2026-02-15 14:13:54 +00:00
but it's not as convenient or advanced as simstr.< / span > < / span > < / td > < td class = "benchmarkresult" > 53.1< / td > < td class = "benchmarkresult" > 49.2< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 222< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L126" > Concat email std::string append< / a > < span class = "tooltiptext code" > std::string email_concat_std(std::string name, std::string_view domain, std::string_view tld) {
2026-02-14 10:09:54 +00:00
return name.append(" @" ).append(domain).append(" ." ).append(tld);
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 72.9< / td > < td class = "benchmarkresult" > 98.9< / td > < td class = "benchmarkresult" > 184< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 636< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L142" > Concat email std::string by strexpr< / a > < span class = "tooltiptext code" > std::string email_concat_std_expr(std::string_view name, std::string_view domain, std::string_view tld) {
2026-02-14 10:09:54 +00:00
return +name + " @" + domain + " ." + tld;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 43.5< / td > < td class = "benchmarkresult" > 37.6< / td > < td class = "benchmarkresult" > 113< / td > < td class = "benchmarkresult" > 112< / td > < td class = "benchmarkresult" > 159< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L157" > Concat email stringa< / a > < span class = "tooltiptext code" > stringa email_concat_sim_expr(ssa name, ssa domain, ssa tld) {
2026-02-14 10:09:54 +00:00
return name + " @" + domain + " ." + tld;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 38.9< / td > < td class = "benchmarkresult" > 40.9< / td > < td class = "benchmarkresult" > 96.2< / td > < td class = "benchmarkresult" > 98.1< / td > < td class = "benchmarkresult" > 133< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n c a t e n a t e e m a i l ' ] = { i d : ' b s 1 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Concat email std::format',data:[170,190,205,253,993]},
{name:'Concat email std::stringstream',data:[325,324,833,946,2513]},
{name:'Concat email stringzilla append',data:[142,120,267,289,574]},
{name:'Concat email stringzilla concat',data:[53.1,49.2,127,134,222]},
{name:'Concat email std::string append',data:[72.9,98.9,184,194,636]},
{name:'Concat email std::string by strexpr',data:[43.5,37.6,113,112,159]},
{name:'Concat email stringa',data:[38.9,40.9,96.2,98.1,133]}
2026-02-14 10:09:54 +00:00
]}< / script >
< div class = "benchset" id = "bs2" > < h4 > < a id = "bs70109915512075798510" href = "#bs70109915512075798510" > #< / a > Concatenate string + Number + " Literal" < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L181" > Concat std::string and number by std to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToStd(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 220< / td > < td class = "benchmarkresult" > 223< / td > < td class = "benchmarkresult" > 271< / td > < td class = "benchmarkresult" > 314< / td > < td class = "benchmarkresult" > 1951< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L192" > Concat std::string and number by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStd(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 162< / td > < td class = "benchmarkresult" > 206< / td > < td class = "benchmarkresult" > 974< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L203" > Concat stringa and number by StrExpr to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSim(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > 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,
2026-02-15 14:13:54 +00:00
while in stringa , the entire test is included in SSO.< / span > < / span > < / td > < td class = "benchmarkresult" > 65.3< / td > < td class = "benchmarkresult" > 73.6< / td > < td class = "benchmarkresult" > 71.6< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 369< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L214" > Concat stringa and number by e_concat to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimConcat(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = e_concat(" " , s1, i, " end" );
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 69.7< / td > < td class = "benchmarkresult" > 78.5< / td > < td class = "benchmarkresult" > 74.8< / td > < td class = "benchmarkresult" > 109< / td > < td class = "benchmarkresult" > 367< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n c a t e n a t e s t r i n g + N u m b e r + " L i t e r a l " ' ] = { i d : ' b s 2 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Concat std::string and number by std to std::string',data:[220,223,271,314,1951]},
{name:'Concat std::string and number by StrExpr to std::string',data:[104,102,162,206,974]},
{name:'Concat stringa and number by StrExpr to simstr::stringa',data:[65.3,73.6,71.6,102,369]},
{name:'Concat stringa and number by e_concat to simstr::stringa',data:[69.7,78.5,74.8,109,367]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs3" > < h4 > < a id = "bs146911715078927772520" href = "#bs146911715078927772520" > #< / a > Concatenate string + Hex Number + " Literal" < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L231" > Concat std::string and format hex number and literal to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToFmtHex(benchmark::State& state) {
2026-01-30 14:30:09 +00:00
// 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);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = s1 + std::format(" {:#x}" , i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 692< / td > < td class = "benchmarkresult" > 695< / td > < td class = "benchmarkresult" > 713< / td > < td class = "benchmarkresult" > 1073< / td > < td class = "benchmarkresult" > 3765< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L244" > std::format std::string and hex number by literal to std::string< / a > < span class = "tooltiptext code" > void ConcatAllFmtToHex(benchmark::State& state) {
2026-01-30 14:30:09 +00:00
// 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);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = std::format(" {}{:#x} end" , s1, i);
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 922< / td > < td class = "benchmarkresult" > 995< / td > < td class = "benchmarkresult" > 1544< / td > < td class = "benchmarkresult" > 1843< / td > < td class = "benchmarkresult" > 4994< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L256" > Concat std::string and std::to_chars and string to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToCharsHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// 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);
2026-01-30 14:30:09 +00:00
// it worked only for char :(
char buf[40];
size_t len = std::to_chars(buf, buf + std::size(buf), i, 16).ptr - buf;
std::string str = s1 + " 0x" + std::string(buf, len) + " end" ;
2026-01-21 11:59:17 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 198< / td > < td class = "benchmarkresult" > 250< / td > < td class = "benchmarkresult" > 192< / td > < td class = "benchmarkresult" > 255< / td > < td class = "benchmarkresult" > 1114< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L271" > Concat std::string and hex number and literal by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStdHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// 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);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-02-08 11:17:03 +00:00
std::string str = +s1 + i / 1_f16 + " end" ;
2026-01-21 11:59:17 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 91.6< / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 885< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L284" > Concat stringa and hex number and literal by StrExpr to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// 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);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-02-08 11:17:03 +00:00
stringa str = s1 + i / 1_f16 + " end" ;
2026-01-21 11:59:17 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 122< / td > < td class = "benchmarkresult" > 72.9< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 252< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L297" > Concat stringa and hex number and literal by e_concat to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexC(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
// 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);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-02-08 11:17:03 +00:00
stringa str = e_concat(" " , s1, i / 1_f16, " end" );
2026-01-29 20:48:41 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 77.5< / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 276< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L310" > Subst stringa and hex number by e_subst literal to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexS(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
// 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);
2026-02-08 11:17:03 +00:00
stringa str = e_subst(" {}{} end" , s1, i / 1_f16);
2026-01-29 20:48:41 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 174< / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 176< / td > < td class = "benchmarkresult" > 548< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L322" > Subst stringa and hex number by e_vsubst stra to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexVS(benchmark::State& state) {
2026-01-31 14:24:12 +00:00
// 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);
2026-02-08 11:17:03 +00:00
stringa str = e_vsubst(" {}{} end" _ss, s1, i / 1_f16);
2026-01-31 14:24:12 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 312< / td > < td class = "benchmarkresult" > 304< / td > < td class = "benchmarkresult" > 287< / td > < td class = "benchmarkresult" > 365< / td > < td class = "benchmarkresult" > 1724< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n c a t e n a t e s t r i n g + H e x N u m b e r + " L i t e r a l " ' ] = { i d : ' b s 3 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Concat std::string and format hex number and literal to std::string',data:[692,695,713,1073,3765]},
{name:'std::format std::string and hex number by literal to std::string',data:[922,995,1544,1843,4994]},
{name:'Concat std::string and std::to_chars and string to std::string',data:[198,250,192,255,1114]},
{name:'Concat std::string and hex number and literal by StrExpr to std::string',data:[132,125,91.6,114,885]},
{name:'Concat stringa and hex number and literal by StrExpr to simstr::stringa',data:[116,122,72.9,102,252]},
{name:'Concat stringa and hex number and literal by e_concat to simstr::stringa',data:[124,128,77.5,104,276]},
{name:'Subst stringa and hex number by e_subst literal to simstr::stringa',data:[181,174,154,176,548]},
{name:'Subst stringa and hex number by e_vsubst stra to simstr::stringa',data:[312,304,287,365,1724]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs4" > < h4 > < a id = "bs32341904136562619220" href = "#bs32341904136562619220" > #< / a > format/vformat and subst/vsubst octal number to 32 symbols result< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L344" > " abcdefghihklmopqr " _ss + i / 0x8a010_fmt + " end" < / a > < span class = "tooltiptext code" > void ConcatSimToSimOct(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
2026-02-08 11:17:03 +00:00
stringa str = " abcdefghihklmopqr " _ss + i / 0x8a010_fmt + " end" ;
2026-02-03 07:38:21 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 276< / td > < td class = "benchmarkresult" > 264< / td > < td class = "benchmarkresult" > 671< / td > < td class = "benchmarkresult" > 682< / td > < td class = "benchmarkresult" > 930< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L353" > e_subst(" abcdefghihklmopqr {} end" , i / 0x8a010_fmt)< / a > < span class = "tooltiptext code" > void SubstSimToSimOct(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
2026-02-08 11:17:03 +00:00
stringa str = e_subst(" abcdefghihklmopqr {} end" , i / 0x8a010_fmt);
2026-02-03 07:38:21 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 352< / td > < td class = "benchmarkresult" > 318< / td > < td class = "benchmarkresult" > 750< / td > < td class = "benchmarkresult" > 798< / td > < td class = "benchmarkresult" > 1123< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L362" > e_vsubst(pattern, i / 0x8a010_fmt)< / a > < span class = "tooltiptext code" > void VSubstSimToSimOct(benchmark::State& state) {
2026-02-08 11:17:03 +00:00
ssa pattern = " abcdefghihklmopqr {} end" ;
2026-02-03 07:38:21 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
2026-02-04 14:25:40 +00:00
stringa str = e_vsubst(pattern, i / 0x8a010_fmt);
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 616< / td > < td class = "benchmarkresult" > 583< / td > < td class = "benchmarkresult" > 1081< / td > < td class = "benchmarkresult" > 1128< / td > < td class = "benchmarkresult" > 2923< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L402" > fmt::format(FMT_COMPILE(" abcdefghihklmopqr {:#010o} end" ), i)< / a > < span class = "tooltiptext code" > void FmtFormatComp(benchmark::State& state) {
2026-02-04 14:25:40 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
2026-02-08 11:17:03 +00:00
std::string str = fmt::format(FMT_COMPILE(" abcdefghihklmopqr {:#010o} end" ), i);
2026-02-03 07:38:21 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 755< / td > < td class = "benchmarkresult" > 809< / td > < td class = "benchmarkresult" > 1449< / td > < td class = "benchmarkresult" > 1577< / td > < td class = "benchmarkresult" > 4411< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L411" > fmt::format(" abcdefghihklmopqr {:#010o} end" , i)< / a > < span class = "tooltiptext code" > void FmtFormat(benchmark::State& state) {
2026-02-08 11:17:03 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::string str = fmt::format(" abcdefghihklmopqr {:#010o} end" , i);
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 894< / td > < td class = "benchmarkresult" > 882< / td > < td class = "benchmarkresult" > 1364< / td > < td class = "benchmarkresult" > 1535< / td > < td class = "benchmarkresult" > 4578< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L372" > std::format(" abcdefghihklmopqr {:#010o} end" , i)< / a > < span class = "tooltiptext code" > void FormatStdToStdOct(benchmark::State& state) {
2026-02-08 11:17:03 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::string str = std::format(" abcdefghihklmopqr {:#010o} end" , i);
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 992< / td > < td class = "benchmarkresult" > 1261< / td > < td class = "benchmarkresult" > 1699< / td > < td class = "benchmarkresult" > 1931< / td > < td class = "benchmarkresult" > 5729< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L381" > std::vformat(pattern, std::make_format_args(i))< / a > < span class = "tooltiptext code" > void VFormatStdToStdOct(benchmark::State& state) {
2026-02-08 11:17:03 +00:00
std::string_view pattern = " abcdefghihklmopqr {:#010o} end" ;
2026-02-03 07:38:21 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::string str = std::vformat(pattern, std::make_format_args(i));
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1000< / td > < td class = "benchmarkresult" > 1151< / td > < td class = "benchmarkresult" > 1586< / td > < td class = "benchmarkresult" > 1914< / td > < td class = "benchmarkresult" > 5777< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L391" > strm < < " abcdefghihklmopqr 0" < < std::oct < < std::setw(9) < < std::setfill(' 0' ) < < i < < " end" < / a > < span class = "tooltiptext code" > void StreamStdToStdOct(benchmark::State& state) {
2026-02-04 14:25:40 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::stringstream strm;
2026-02-08 11:17:03 +00:00
strm < < " abcdefghihklmopqr 0" < < std::oct < < std::setw(9) < < std::setfill(' 0' ) < < i < < " end" ;
2026-02-04 14:25:40 +00:00
std::string str = strm.str();
benchmark::DoNotOptimize(str);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2055< / td > < td class = "benchmarkresult" > 2133< / td > < td class = "benchmarkresult" > 6885< / td > < td class = "benchmarkresult" > 7062< / td > < td class = "benchmarkresult" > 18843< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' f o r m a t / v f o r m a t a n d s u b s t / v s u b s t o c t a l n u m b e r t o 3 2 s y m b o l s r e s u l t ' ] = { i d : ' b s 4 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'"abcdefghihklmopqr "_ss + i / 0x8a010_fmt + " end"',data:[276,264,671,682,930]},
{name:'e_subst("abcdefghihklmopqr {} end", i / 0x8a010_fmt)',data:[352,318,750,798,1123]},
{name:'e_vsubst(pattern, i / 0x8a010_fmt)',data:[616,583,1081,1128,2923]},
{name:'fmt::format(FMT_COMPILE("abcdefghihklmopqr {:#010o} end"), i)',data:[755,809,1449,1577,4411]},
{name:'fmt::format("abcdefghihklmopqr {:#010o} end", i)',data:[894,882,1364,1535,4578]},
{name:'std::format("abcdefghihklmopqr {:#010o} end", i)',data:[992,1261,1699,1931,5729]},
{name:'std::vformat(pattern, std::make_format_args(i))',data:[1000,1151,1586,1914,5777]},
{name:'strm < < "abcdefghihklmopqr 0" < < std::oct < < std::setw ( 9 ) < < std::setfill ( \ ' 0 \ ' ) < < i < < " end " ' , data: [ 2055 , 2133 , 6885 , 7062 , 18843 ] }
2026-02-03 07:38:21 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs5" > < h4 > < a id = "bs59672599204338055190" href = "#bs59672599204338055190" > #< / a > Concatenate string + " Literal" < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L431" > Concat std::string by std to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToStdS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 44.3< / td > < td class = "benchmarkresult" > 49.8< / td > < td class = "benchmarkresult" > 40.8< / td > < td class = "benchmarkresult" > 55.6< / td > < td class = "benchmarkresult" > 155< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L442" > Concat std::string by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStdS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 31.3< / td > < td class = "benchmarkresult" > 32.3< / td > < td class = "benchmarkresult" > 38.2< / td > < td class = "benchmarkresult" > 79.3< / td > < td class = "benchmarkresult" > 175< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L453" > Concat stringa by StrExpr to stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
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);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.4< / td > < td class = "benchmarkresult" > 26.4< / td > < td class = "benchmarkresult" > 28.7< / td > < td class = "benchmarkresult" > 50.7< / td > < td class = "benchmarkresult" > 146< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n c a t e n a t e s t r i n g + " L i t e r a l " ' ] = { i d : ' b s 5 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Concat std::string by std to std::string',data:[44.3,49.8,40.8,55.6,155]},
{name:'Concat std::string by StrExpr to std::string',data:[31.3,32.3,38.2,79.3,175]},
{name:'Concat stringa by StrExpr to stringa',data:[28.4,26.4,28.7,50.7,146]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs6" > < h4 > < a id = "bs68116594352702954700" href = "#bs68116594352702954700" > #< / a > Find three concatenated string in string_view< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L469" > Find concat three std::string< / a > < span class = "tooltiptext code" > size_t find_pos_str(std::string_view src, std::string_view name) {
2026-01-21 11:59:17 +00:00
// before C++26 we can not concatenate string and string_view...
return src.find(" \n- " s + std::string{name} + " -\n" );
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 146< / td > < td class = "benchmarkresult" > 208< / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 501< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L474" > Find concat three strexpr< / a > < span class = "tooltiptext code" > size_t find_pos_exp(ssa src, ssa name) {
2026-01-21 11:59:17 +00:00
return src.find(std::string{" \n- " + name + " -\n" });
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 49.3< / td > < td class = "benchmarkresult" > 39.0< / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 288< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L478" > Find concat three simstr< / a > < span class = "tooltiptext code" > size_t find_pos_sim(ssa src, ssa name) {
2026-01-21 11:59:17 +00:00
return src.find(lstringa< 200>{" \n- " + name + " -\n" });
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Если результат конкатенации меньше 207 символов,
он собирается в буфере на стеке, без аллокации и деалокации.
If the concatenation result is less than 207 characters,
2026-02-15 14:13:54 +00:00
it is collected in a stack-based buffer, without allocation or deallocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 19.4< / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 21.5< / td > < td class = "benchmarkresult" > 28.4< / td > < td class = "benchmarkresult" > 174< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L482" > Find concat three stringzilla string< / a > < span class = "tooltiptext code" > size_t find_pos_sz(sz::string_view src, sz::string_view name) {
2026-02-14 10:09:54 +00:00
return src.find(sz::string{" \n- " }.append(name).append(" -\n" ));
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 143< / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 214< / td > < td class = "benchmarkresult" > 228< / td > < td class = "benchmarkresult" > 621< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' F i n d t h r e e c o n c a t e n a t e d s t r i n g i n s t r i n g _ v i e w ' ] = { i d : ' b s 6 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Find concat three std::string',data:[114,146,208,219,501]},
{name:'Find concat three strexpr',data:[49.3,39.0,114,125,288]},
{name:'Find concat three simstr',data:[19.4,16.4,21.5,28.4,174]},
{name:'Find concat three stringzilla string',data:[143,139,214,228,621]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs7" > < h4 > < a id = "bs145290966789248325200" href = "#bs145290966789248325200" > #< / a > Build Type Name< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L558" > BuildTypeNameStr 0/0< / a > < span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.09< / td > < td class = "benchmarkresult" > 10.8< / td > < td class = "benchmarkresult" > 8.40< / td > < td class = "benchmarkresult" > 17.4< / td > < td class = "benchmarkresult" > 27.5< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L570" > BuildTypeNameExp 0/0< / a > < span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.90< / td > < td class = "benchmarkresult" > 8.49< / td > < td class = "benchmarkresult" > 7.43< / td > < td class = "benchmarkresult" > 12.8< / td > < td class = "benchmarkresult" > 29.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L577" > BuildTypeNameSim 0/0< / a > < span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.95< / td > < td class = "benchmarkresult" > 4.96< / td > < td class = "benchmarkresult" > 7.80< / td > < td class = "benchmarkresult" > 15.1< / td > < td class = "benchmarkresult" > 38.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L558" > BuildTypeNameStr 10/10< / a > < span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 56.3< / td > < td class = "benchmarkresult" > 87.2< / td > < td class = "benchmarkresult" > 58.8< / td > < td class = "benchmarkresult" > 77.5< / td > < td class = "benchmarkresult" > 661< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L570" > BuildTypeNameExp 10/10< / a > < span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 26.8< / td > < td class = "benchmarkresult" > 32.1< / td > < td class = "benchmarkresult" > 39.5< / td > < td class = "benchmarkresult" > 201< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L577" > BuildTypeNameSim 10/10< / a > < span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.8< / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 38.3< / td > < td class = "benchmarkresult" > 105< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' B u i l d T y p e N a m e ' ] = { i d : ' b s 7 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'BuildTypeNameStr 0/0',data:[7.09,10.8,8.40,17.4,27.5]},
{name:'BuildTypeNameExp 0/0',data:[6.90,8.49,7.43,12.8,29.2]},
{name:'BuildTypeNameSim 0/0',data:[4.95,4.96,7.80,15.1,38.8]},
{name:'BuildTypeNameStr 10/10',data:[56.3,87.2,58.8,77.5,661]},
{name:'BuildTypeNameExp 10/10',data:[31.0,26.8,32.1,39.5,201]},
{name:'BuildTypeNameSim 10/10',data:[22.8,23.2,25.6,38.3,105]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs8" > < h4 > < a id = "bs54035654251116789780" href = "#bs54035654251116789780" > #< / a > Replace string by copy< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L631" > Concat with replace str< / a > < span class = "tooltiptext code" > std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
2026-01-21 11:59:17 +00:00
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) + " >" ;
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 213< / td > < td class = "benchmarkresult" > 235< / td > < td class = "benchmarkresult" > 309< / td > < td class = "benchmarkresult" > 343< / td > < td class = "benchmarkresult" > 1091< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L649" > Concat with replace exp< / a > < span class = "tooltiptext code" > std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
2026-01-21 11:59:17 +00:00
return " < " + e_repl(from, pattern, repl) + " >" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr строковое выражение для замены подстрок
есть "из коробки".
2026-02-15 14:13:54 +00:00
simstr has a string expression for replacing substrings out of the box.< / span > < / span > < / td > < td class = "benchmarkresult" > 147< / td > < td class = "benchmarkresult" > 142< / td > < td class = "benchmarkresult" > 217< / td > < td class = "benchmarkresult" > 225< / td > < td class = "benchmarkresult" > 502< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' R e p l a c e s t r i n g b y c o p y ' ] = { i d : ' b s 8 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Concat with replace str',data:[213,235,309,343,1091]},
{name:'Concat with replace exp',data:[147,142,217,225,502]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs9" > < h4 > < a id = "bs77666948964429305550" href = "#bs77666948964429305550" > #< / a > Create Empty Str< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > std::string e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Пустые строки, ничего необычного.
2026-02-15 14:13:54 +00:00
Empty lines, nothing unusual.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 2.59< / td > < td class = "benchmarkresult" > 2.63< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > std::string_view e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.369< / td > < td class = "benchmarkresult" > 0.770< / td > < td class = "benchmarkresult" > 0.366< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.19< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > ssa e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.371< / td > < td class = "benchmarkresult" > 0.188< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.14< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > stringa e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.758< / td > < td class = "benchmarkresult" > 0.777< / td > < td class = "benchmarkresult" > 0.745< / td > < td class = "benchmarkresult" > 2.20< / td > < td class = "benchmarkresult" > 2.97< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > lstringa< 20> e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 2.58< / td > < td class = "benchmarkresult" > 3.67< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L683" > lstringa< 40> e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.15< / td > < td class = "benchmarkresult" > 1.18< / td > < td class = "benchmarkresult" > 1.16< / td > < td class = "benchmarkresult" > 2.54< / td > < td class = "benchmarkresult" > 3.54< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e E m p t y S t r ' ] = { i d : ' b s 9 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string e;',data:[1.11,1.14,1.10,2.59,2.63]},
{name:'std::string_view e;',data:[0.369,0.770,0.366,1.84,2.19]},
{name:'ssa e;',data:[0.371,0.188,0.364,1.84,2.14]},
{name:'stringa e;',data:[0.758,0.777,0.745,2.20,2.97]},
{name:'lstringa< 20 > e;',data:[1.14,1.14,1.12,2.58,3.67]},
{name:'lstringa< 40 > e;',data:[1.15,1.18,1.16,2.54,3.54]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs10" > < h4 > < a id = "bs181001525395597238060" href = "#bs181001525395597238060" > #< / a > Create Str from short literal (9 symbols)< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > std::string e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Короткий литерал помещается во внутренний буфер std::string,
2026-01-21 11:59:17 +00:00
время тратится только на копирование 10 байтов.
The short literal is placed in the internal std::string buffer;
2026-02-15 14:13:54 +00:00
time is spent only copying 10 bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 1.91< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 2.53< / td > < td class = "benchmarkresult" > 3.39< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > std::string_view e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И string_view, и ssa - по сути одно и то же:
2026-01-21 11:59:17 +00:00
указатель на текст и е г о длина.
Both string_view and ssa are essentially the same thing:
2026-02-15 14:13:54 +00:00
a pointer to text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.760< / td > < td class = "benchmarkresult" > 0.765< / td > < td class = "benchmarkresult" > 0.736< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.19< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > ssa e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.380< / td > < td class = "benchmarkresult" > 0.765< / td > < td class = "benchmarkresult" > 0.363< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 2.14< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > stringa e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringa при инициализации константным литералом так же
2026-01-21 11:59:17 +00:00
сохраняет только указатель на текст и е г о длину.
When initialized with a constant literal, stringa also stores
2026-02-15 14:13:54 +00:00
only a pointer to the text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 3.04< / td > < td class = "benchmarkresult" > 3.03< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > lstringa< 20> e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Внутреннего буфера хватает для размещения символов,
2026-01-21 11:59:17 +00:00
время уходит только на копирование байтов.
The internal buffer is sufficient to accommodate characters;
2026-02-15 14:13:54 +00:00
time is spent only on copying bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.91< / td > < td class = "benchmarkresult" > 1.90< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 3.96< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L698" > lstringa< 40> e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.92< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.62< / td > < td class = "benchmarkresult" > 3.99< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e S t r f r o m s h o r t l i t e r a l ( 9 s y m b o l s ) ' ] = { i d : ' b s 1 0 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string e = "Test text";',data:[1.85,1.91,1.85,2.53,3.39]},
{name:'std::string_view e = "Test text";',data:[0.760,0.765,0.736,1.84,2.19]},
{name:'ssa e = "Test text";',data:[0.380,0.765,0.363,1.82,2.14]},
{name:'stringa e = "Test text";',data:[1.13,1.13,1.11,3.04,3.03]},
{name:'lstringa< 20 > e = "Test text";',data:[1.91,1.90,1.85,2.57,3.96]},
{name:'lstringa< 40 > e = "Test text";',data:[1.83,1.92,1.84,2.62,3.99]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs11" > < h4 > < a id = "bs132333183298742730280" href = "#bs132333183298742730280" > #< / a > Create Str from long literal (30 symbols)< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > std::string e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вот тут уже литерал не помещается во внутренний буфер,
возникает аллокация и копирование 30-и байтов.
2026-01-21 11:59:17 +00:00
Н о как же отстает аллокация под Windows от Linux'а , 20 vs 70 ns...
Here, the literal doesn't fit into the internal buffer,
and 30 bytes are allocated and copied.
2026-02-15 14:13:54 +00:00
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...< / span > < / span > < / td > < td class = "benchmarkresult" > 21.7< / td > < td class = "benchmarkresult" > 20.2< / td > < td class = "benchmarkresult" > 76.0< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 69.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > std::string_view e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > string_view и ssa по прежнему ничего не делают, кроме
2026-01-21 11:59:17 +00:00
запоминания указателя на текст и е г о размера.
string_view and ssa still do nothing except
2026-02-15 14:13:54 +00:00
remember the pointer to the text and its size.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.735< / td > < td class = "benchmarkresult" > 0.759< / td > < td class = "benchmarkresult" > 0.735< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.17< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > ssa e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.383< / td > < td class = "benchmarkresult" > 0.767< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.14< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > stringa e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringa на константных литералах не отстает!
2026-02-15 14:13:54 +00:00
stringa doesn't lag behind on constant literals!< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.20< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 2.20< / td > < td class = "benchmarkresult" > 2.97< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > lstringa< 20> e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > lstringa< 20 > может вместить в себя до 23 символов,
2026-01-21 11:59:17 +00:00
Очевидно, что для 30-и символов уже нужна аллокация.
2026-02-15 14:13:54 +00:00
Obviously, 30 characters already require allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 21.0< / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 73.7< / td > < td class = "benchmarkresult" > 74.5< / td > < td class = "benchmarkresult" > 69.7< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L713" > lstringa< 40> e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А в lstringa< 40 > влезает до 47 символов, так что просто
2026-01-21 11:59:17 +00:00
копируется 30 байтов.
And lstringa< 40 > can hold up to 47 characters, so 30
2026-02-15 14:13:54 +00:00
bytes are simply copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 2.59< / td > < td class = "benchmarkresult" > 1.94< / td > < td class = "benchmarkresult" > 2.54< / td > < td class = "benchmarkresult" > 3.34< / td > < td class = "benchmarkresult" > 16.5< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e S t r f r o m l o n g l i t e r a l ( 3 0 s y m b o l s ) ' ] = { i d : ' b s 1 1 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string e = "123456789012345678901234567890";',data:[21.7,20.2,76.0,77.2,69.1]},
{name:'std::string_view e = "123456789012345678901234567890";',data:[0.735,0.759,0.735,1.84,2.17]},
{name:'ssa e = "123456789012345678901234567890";',data:[0.383,0.767,0.364,1.84,2.14]},
{name:'stringa e = "123456789012345678901234567890";',data:[1.10,1.20,1.10,2.20,2.97]},
{name:'lstringa< 20 > e = "123456789012345678901234567890";',data:[21.0,24.0,73.7,74.5,69.7]},
{name:'lstringa< 40 > e = "123456789012345678901234567890";',data:[2.59,1.94,2.54,3.34,16.5]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs12" > < h4 > < a id = "bs6234433963744178700" href = "#bs6234433963744178700" > #< / a > Create copy of Str with 9 symbols< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > std::string e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Строка в пределах SSO, так что просто копирует байты.
2026-02-15 14:13:54 +00:00
The string is within the SSO, so it just copies the bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 5.27< / td > < td class = "benchmarkresult" > 5.67< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 5.36< / td > < td class = "benchmarkresult" > 6.73< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > std::string_view e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.383< / td > < td class = "benchmarkresult" > 0.378< / td > < td class = "benchmarkresult" > 0.366< / td > < td class = "benchmarkresult" > 2.92< / td > < td class = "benchmarkresult" > 2.20< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > ssa e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > ssa и string_view не владеют строкой, копируется
2026-01-21 11:59:17 +00:00
только информация о строке.
ssa and string_view don't own the string; only the
2026-02-15 14:13:54 +00:00
string information is copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.376< / td > < td class = "benchmarkresult" > 0.391< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 2.92< / td > < td class = "benchmarkresult" > 2.21< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > stringa e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Копирование stringa происходит быстро,
2026-01-21 11:59:17 +00:00
особенно если она инициализирована литералом.
Copying a stringa is fast,
2026-02-15 14:13:54 +00:00
especially if it is initialized with a literal.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.31< / td > < td class = "benchmarkresult" > 4.11< / td > < td class = "benchmarkresult" > 4.66< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > lstringa< 20> e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В обоих случаях хватает внутреннего буфера.
2026-02-15 14:13:54 +00:00
In both cases, the internal buffer is sufficient.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.50< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.47< / td > < td class = "benchmarkresult" > 4.71< / td > < td class = "benchmarkresult" > 7.15< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L728" > lstringa< 40> e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Только копируются байты.
2026-02-15 14:13:54 +00:00
Only bytes are copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.52< / td > < td class = "benchmarkresult" > 1.15< / td > < td class = "benchmarkresult" > 1.48< / td > < td class = "benchmarkresult" > 5.44< / td > < td class = "benchmarkresult" > 7.34< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e c o p y o f S t r w i t h 9 s y m b o l s ' ] = { i d : ' b s 1 2 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string e = "Test text"; auto c{e};',data:[5.27,5.67,1.83,5.36,6.73]},
{name:'std::string_view e = "Test text"; auto c{e};',data:[0.383,0.378,0.366,2.92,2.20]},
{name:'ssa e = "Test text"; auto c{e};',data:[0.376,0.391,0.364,2.92,2.21]},
{name:'stringa e = "Test text"; auto c{e};',data:[1.11,1.12,1.31,4.11,4.66]},
{name:'lstringa< 20 > e = "Test text"; auto c{e};',data:[1.50,1.14,1.47,4.71,7.15]},
{name:'lstringa< 40 > e = "Test text"; auto c{e};',data:[1.52,1.15,1.48,5.44,7.34]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs13" > < h4 > < a id = "bs76384575499199461500" href = "#bs76384575499199461500" > #< / a > Create copy of Str with 30 symbols< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > std::string e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Копирования длинной строки вызывает аллокацию,
2026-01-21 11:59:17 +00:00
SSO уже не хватает. И снова как же отстаёт аллокация под Windows...
Copying a long string causes allocations,
2026-02-15 14:13:54 +00:00
SSO is no longer sufficient. And again, how allocation lags under Windows...< / span > < / span > < / td > < td class = "benchmarkresult" > 19.1< / td > < td class = "benchmarkresult" > 24.6< / td > < td class = "benchmarkresult" > 72.4< / td > < td class = "benchmarkresult" > 78.7< / td > < td class = "benchmarkresult" > 119< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > std::string_view e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.752< / td > < td class = "benchmarkresult" > 0.775< / td > < td class = "benchmarkresult" > 0.734< / td > < td class = "benchmarkresult" > 1.49< / td > < td class = "benchmarkresult" > 2.22< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > ssa e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.375< / td > < td class = "benchmarkresult" > 0.747< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 1.52< / td > < td class = "benchmarkresult" > 2.16< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > stringa e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А вот у stringa копирование литерала не зависит от е г о длины,
2026-01-21 11:59:17 +00:00
сравни с предыдущим бенчмарком.
But with stringa, literal copying doesn't depend on its length,
2026-02-15 14:13:54 +00:00
compare with the previous benchmark.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.19< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.93< / td > < td class = "benchmarkresult" > 2.98< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > lstringa< 20> e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Н е влезает, аллокация.
2026-02-15 14:13:54 +00:00
Doesn't fit, allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 21.5< / td > < td class = "benchmarkresult" > 20.4< / td > < td class = "benchmarkresult" > 75.7< / td > < td class = "benchmarkresult" > 79.5< / td > < td class = "benchmarkresult" > 72.7< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L745" > lstringa< 40> e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Уложили во внутренний буфер.
2026-02-15 14:13:54 +00:00
Placed in the internal buffer.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.61< / td > < td class = "benchmarkresult" > 4.84< / td > < td class = "benchmarkresult" > 4.84< / td > < td class = "benchmarkresult" > 7.37< / td > < td class = "benchmarkresult" > 50.4< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e c o p y o f S t r w i t h 3 0 s y m b o l s ' ] = { i d : ' b s 1 3 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string e = "123456789012345678901234567890"; auto c{e};',data:[19.1,24.6,72.4,78.7,119]},
{name:'std::string_view e = "123456789012345678901234567890"; auto c{e};',data:[0.752,0.775,0.734,1.49,2.22]},
{name:'ssa e = "123456789012345678901234567890"; auto c{e};',data:[0.375,0.747,0.364,1.52,2.16]},
{name:'stringa e = "123456789012345678901234567890"; auto c{e};',data:[1.11,1.19,1.84,2.93,2.98]},
{name:'lstringa< 20 > e = "123456789012345678901234567890"; auto c{e};',data:[21.5,20.4,75.7,79.5,72.7]},
{name:'lstringa< 40 > e = "123456789012345678901234567890"; auto c{e};',data:[4.61,4.84,4.84,7.37,50.4]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs14" > < h4 > < a id = "bs21623892135774528620" href = "#bs21623892135774528620" > #< / a > Find 9 symbols text in end of 99 symbols text< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > sz::string::find;< / a > < span class = "tooltiptext code" > template< typename T>
2026-02-14 10:09:54 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringzilla более заточена на поиск больших строк в больших строках.
2026-02-15 14:13:54 +00:00
stringzilla is more focused on searching large strings within large strings.< / span > < / span > < / td > < td class = "benchmarkresult" > 95.0< / td > < td class = "benchmarkresult" > 95.3< / td > < td class = "benchmarkresult" > 98.2< / td > < td class = "benchmarkresult" > 117< / td > < td class = "benchmarkresult" > 231< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > std::string::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь "победила дружба", у всех типов по колонке примерно одинаково.
2026-01-21 11:59:17 +00:00
Однако, Windows и Linux явно в разных весовых категориях.
Here, "friendship wins," with all types scoring roughly equally.
2026-02-15 14:13:54 +00:00
However, Windows and Linux are clearly in different weight classes.< / span > < / span > < / td > < td class = "benchmarkresult" > 7.29< / td > < td class = "benchmarkresult" > 6.95< / td > < td class = "benchmarkresult" > 39.9< / td > < td class = "benchmarkresult" > 39.2< / td > < td class = "benchmarkresult" > 99.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > std::string_view::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.54< / td > < td class = "benchmarkresult" > 8.19< / td > < td class = "benchmarkresult" > 52.2< / td > < td class = "benchmarkresult" > 39.0< / td > < td class = "benchmarkresult" > 96.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > ssa::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.60< / td > < td class = "benchmarkresult" > 6.99< / td > < td class = "benchmarkresult" > 18.9< / td > < td class = "benchmarkresult" > 21.9< / td > < td class = "benchmarkresult" > 97.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > stringa::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 8.42< / td > < td class = "benchmarkresult" > 6.91< / td > < td class = "benchmarkresult" > 19.4< / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 99.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > lstringa< 20>::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.84< / td > < td class = "benchmarkresult" > 6.65< / td > < td class = "benchmarkresult" > 17.6< / td > < td class = "benchmarkresult" > 21.9< / td > < td class = "benchmarkresult" > 115< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L762" > lstringa< 40>::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.91< / td > < td class = "benchmarkresult" > 6.58< / td > < td class = "benchmarkresult" > 18.0< / td > < td class = "benchmarkresult" > 22.2< / td > < td class = "benchmarkresult" > 115< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' F i n d 9 s y m b o l s t e x t i n e n d o f 9 9 s y m b o l s t e x t ' ] = { i d : ' b s 1 4 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'sz::string::find;',data:[95.0,95.3,98.2,117,231]},
{name:'std::string::find;',data:[7.29,6.95,39.9,39.2,99.9]},
{name:'std::string_view::find;',data:[7.54,8.19,52.2,39.0,96.4]},
{name:'ssa::find;',data:[7.60,6.99,18.9,21.9,97.9]},
{name:'stringa::find;',data:[8.42,6.91,19.4,31.0,99.1]},
{name:'lstringa< 20 > ::find;',data:[6.84,6.65,17.6,21.9,115]},
{name:'lstringa< 40 > ::find;',data:[6.91,6.58,18.0,22.2,115]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs15" > < h4 > < a id = "bs170792414351801782640" href = "#bs170792414351801782640" > #< / a > Copy not literal Str with N symbols< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.95< / td > < td class = "benchmarkresult" > 9.01< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 5.24< / td > < td class = "benchmarkresult" > 125< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Явно виден скачок, где заканчивается SSO и начинается аллокация.
Обратите внимание, что WASM - 32-битный, и там размер
2026-02-12 16:47:32 +00:00
SSO у std::string меньше, 10 символов + 0.
2026-01-21 11:59:17 +00:00
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
2026-02-15 14:13:54 +00:00
smaller, as far as I remember: 11 characters + 0.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.3< / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 78.8< / td > < td class = "benchmarkresult" > 79.3< / td > < td class = "benchmarkresult" > 125< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Дальше просто добавляется время на копирование байтов.
2026-02-15 14:13:54 +00:00
Then the time for copying bytes is simply added.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.8< / td > < td class = "benchmarkresult" > 27.8< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 77.7< / td > < td class = "benchmarkresult" > 126< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.5< / td > < td class = "benchmarkresult" > 28.8< / td > < td class = "benchmarkresult" > 77.5< / td > < td class = "benchmarkresult" > 77.5< / td > < td class = "benchmarkresult" > 120< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 27.3< / td > < td class = "benchmarkresult" > 83.0< / td > < td class = "benchmarkresult" > 86.2< / td > < td class = "benchmarkresult" > 124< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.1< / td > < td class = "benchmarkresult" > 27.0< / td > < td class = "benchmarkresult" > 81.2< / td > < td class = "benchmarkresult" > 80.0< / td > < td class = "benchmarkresult" > 123< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 25.3< / td > < td class = "benchmarkresult" > 29.2< / td > < td class = "benchmarkresult" > 83.8< / td > < td class = "benchmarkresult" > 84.8< / td > < td class = "benchmarkresult" > 133< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 31.4< / td > < td class = "benchmarkresult" > 34.2< / td > < td class = "benchmarkresult" > 88.0< / td > < td class = "benchmarkresult" > 88.0< / td > < td class = "benchmarkresult" > 156< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.8< / td > < td class = "benchmarkresult" > 34.0< / td > < td class = "benchmarkresult" > 92.5< / td > < td class = "benchmarkresult" > 88.8< / td > < td class = "benchmarkresult" > 150< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 34.9< / td > < td class = "benchmarkresult" > 37.7< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 97.7< / td > < td class = "benchmarkresult" > 174< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 81.2< / td > < td class = "benchmarkresult" > 81.1< / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 135< / td > < td class = "benchmarkresult" > 217< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > std::string copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Чем длиннее строка, тем дольше создаётся копия.
2026-02-15 14:13:54 +00:00
The longer the string, the longer it takes to create a copy.< / span > < / span > < / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 175< / td > < td class = "benchmarkresult" > 183< / td > < td class = "benchmarkresult" > 263< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь stringa инициализируется не литералом,
2026-01-21 11:59:17 +00:00
а значит, должна сама хранить символы.
Here, stringa is not initialized with a literal,
2026-02-15 14:13:54 +00:00
meaning it must store characters itself.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.35< / td > < td class = "benchmarkresult" > 1.29< / td > < td class = "benchmarkresult" > 4.09< / td > < td class = "benchmarkresult" > 4.83< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Под WASM SSO у stringa составляет 15 символов. Кроме того,
2026-01-21 11:59:17 +00:00
собиралось без поддержки потоков, поэтому атомарный
инкремент заменён на обычный, судя по времени.
Under WASM, stringa has a 15-character SSO. Furthermore,
it was built without thread support, so the atomic
2026-02-15 14:13:54 +00:00
increment was replaced with a regular one, judging by the time.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.34< / td > < td class = "benchmarkresult" > 1.29< / td > < td class = "benchmarkresult" > 4.08< / td > < td class = "benchmarkresult" > 7.81< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > SSO в stringa до 23 символов, и даже 23
2026-01-21 11:59:17 +00:00
копируются быстрее, чем 15 в std::string.
SSO in stringa is up to 23 characters, and even 23
2026-02-15 14:13:54 +00:00
copies faster than 15 in std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.32< / td > < td class = "benchmarkresult" > 1.31< / td > < td class = "benchmarkresult" > 3.99< / td > < td class = "benchmarkresult" > 8.12< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Всё, не влезаем в SSO, а значит, используем shared буфер.
2026-01-21 11:59:17 +00:00
Добавляется время на атомарный инкремент счётчика.
That's it, we're not using SSO, so we're using a shared buffer.
2026-02-15 14:13:54 +00:00
Time is added for the atomic counter increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.7< / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 7.86< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 17.4< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 7.82< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 7.90< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.5< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 7.78< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.7< / td > < td class = "benchmarkresult" > 8.03< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 7.91< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 16.6< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 7.78< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 16.7< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 7.80< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > stringa copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И как видно, кроме инкремента нет накладных расходов,
2026-01-21 11:59:17 +00:00
время копирования не зависит от длины строки.
And as you can see, there are no overhead costs other than the
2026-02-15 14:13:54 +00:00
increment; copying time does not depend on the string length.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.9< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 7.79< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > lstringa< 16 > использует SSO до 23 символов.
2026-01-21 11:59:17 +00:00
А в WASM 32-битная архитектура, SSO до 19 символов.
lstringa< 16 > uses SSO up to 23 characters.
2026-02-15 14:13:54 +00:00
WASM has a 32-bit architecture, so SSO is up to 19 characters.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.52< / td > < td class = "benchmarkresult" > 1.16< / td > < td class = "benchmarkresult" > 1.52< / td > < td class = "benchmarkresult" > 4.08< / td > < td class = "benchmarkresult" > 8.00< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.83< / td > < td class = "benchmarkresult" > 4.98< / td > < td class = "benchmarkresult" > 5.17< / td > < td class = "benchmarkresult" > 8.48< / td > < td class = "benchmarkresult" > 20.7< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.81< / td > < td class = "benchmarkresult" > 5.05< / td > < td class = "benchmarkresult" > 5.12< / td > < td class = "benchmarkresult" > 8.50< / td > < td class = "benchmarkresult" > 88.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И после начинает вести себя при копировании, как std::string.
2026-02-15 14:13:54 +00:00
And then it starts to behave like std::string when copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 25.0< / td > < td class = "benchmarkresult" > 24.6< / td > < td class = "benchmarkresult" > 77.9< / td > < td class = "benchmarkresult" > 78.6< / td > < td class = "benchmarkresult" > 88.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 25.1< / td > < td class = "benchmarkresult" > 24.4< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 83.2< / td > < td class = "benchmarkresult" > 92.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27.4< / td > < td class = "benchmarkresult" > 26.2< / td > < td class = "benchmarkresult" > 84.6< / td > < td class = "benchmarkresult" > 84.0< / td > < td class = "benchmarkresult" > 96.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27.1< / td > < td class = "benchmarkresult" > 27.6< / td > < td class = "benchmarkresult" > 84.6< / td > < td class = "benchmarkresult" > 87.1< / td > < td class = "benchmarkresult" > 97.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.1< / td > < td class = "benchmarkresult" > 27.8< / td > < td class = "benchmarkresult" > 85.7< / td > < td class = "benchmarkresult" > 90.7< / td > < td class = "benchmarkresult" > 130< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 30.7< / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 87.1< / td > < td class = "benchmarkresult" > 89.3< / td > < td class = "benchmarkresult" > 116< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 52.9< / td > < td class = "benchmarkresult" > 55.0< / td > < td class = "benchmarkresult" > 96.6< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 139< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 67.6< / td > < td class = "benchmarkresult" > 64.4< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 178< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 16> copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 87.8< / td > < td class = "benchmarkresult" > 90.0< / td > < td class = "benchmarkresult" > 180< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 221< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.58< / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.45< / td > < td class = "benchmarkresult" > 4.82< / td > < td class = "benchmarkresult" > 8.09< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.90< / td > < td class = "benchmarkresult" > 4.48< / td > < td class = "benchmarkresult" > 5.21< / td > < td class = "benchmarkresult" > 9.21< / td > < td class = "benchmarkresult" > 21.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.83< / td > < td class = "benchmarkresult" > 4.49< / td > < td class = "benchmarkresult" > 5.18< / td > < td class = "benchmarkresult" > 9.42< / td > < td class = "benchmarkresult" > 20.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.78< / td > < td class = "benchmarkresult" > 4.10< / td > < td class = "benchmarkresult" > 5.21< / td > < td class = "benchmarkresult" > 9.49< / td > < td class = "benchmarkresult" > 20.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.59< / td > < td class = "benchmarkresult" > 4.40< / td > < td class = "benchmarkresult" > 8.19< / td > < td class = "benchmarkresult" > 12.2< / td > < td class = "benchmarkresult" > 22.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.15< / td > < td class = "benchmarkresult" > 5.64< / td > < td class = "benchmarkresult" > 8.21< / td > < td class = "benchmarkresult" > 12.2< / td > < td class = "benchmarkresult" > 23.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.02< / td > < td class = "benchmarkresult" > 7.25< / td > < td class = "benchmarkresult" > 8.48< / td > < td class = "benchmarkresult" > 12.7< / td > < td class = "benchmarkresult" > 24.5< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 8.43< / td > < td class = "benchmarkresult" > 7.90< / td > < td class = "benchmarkresult" > 9.79< / td > < td class = "benchmarkresult" > 13.6< / td > < td class = "benchmarkresult" > 26.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Даже 512 символов копируются быстрее, чем
2026-01-21 11:59:17 +00:00
одна аллокация или атомарный инкремент.
Even 512 characters are copied faster than a single
2026-02-15 14:13:54 +00:00
allocation or atomic increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 11.5< / td > < td class = "benchmarkresult" > 10.4< / td > < td class = "benchmarkresult" > 11.2< / td > < td class = "benchmarkresult" > 15.4< / td > < td class = "benchmarkresult" > 28.5< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А дальше уже как у всех.
2026-02-15 14:13:54 +00:00
And then it's like everyone else.< / span > < / span > < / td > < td class = "benchmarkresult" > 57.0< / td > < td class = "benchmarkresult" > 55.7< / td > < td class = "benchmarkresult" > 98.6< / td > < td class = "benchmarkresult" > 99.1< / td > < td class = "benchmarkresult" > 137< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 65.8< / td > < td class = "benchmarkresult" > 66.5< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 174< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L786" > lstringa< 512> copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 92.2< / td > < td class = "benchmarkresult" > 89.3< / td > < td class = "benchmarkresult" > 182< / td > < td class = "benchmarkresult" > 191< / td > < td class = "benchmarkresult" > 220< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o p y n o t l i t e r a l S t r w i t h N s y m b o l s ' ] = { i d : ' b s 1 5 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string copy{str_with_len_N};/15',data:[5.95,9.01,1.85,5.24,125]},
{name:'std::string copy{str_with_len_N};/16',data:[23.3,28.5,78.8,79.3,125]},
{name:'std::string copy{str_with_len_N};/23',data:[23.8,27.8,77.2,77.7,126]},
{name:'std::string copy{str_with_len_N};/24',data:[23.5,28.8,77.5,77.5,120]},
{name:'std::string copy{str_with_len_N};/32',data:[24.0,27.3,83.0,86.2,124]},
{name:'std::string copy{str_with_len_N};/64',data:[23.1,27.0,81.2,80.0,123]},
{name:'std::string copy{str_with_len_N};/128',data:[25.3,29.2,83.8,84.8,133]},
{name:'std::string copy{str_with_len_N};/256',data:[31.4,34.2,88.0,88.0,156]},
{name:'std::string copy{str_with_len_N};/512',data:[28.8,34.0,92.5,88.8,150]},
{name:'std::string copy{str_with_len_N};/1024',data:[34.9,37.7,102,97.7,174]},
{name:'std::string copy{str_with_len_N};/2048',data:[81.2,81.1,123,135,217]},
{name:'std::string copy{str_with_len_N};/4096',data:[120,120,175,183,263]},
{name:'stringa copy{str_with_len_N};/15',data:[1.09,1.35,1.29,4.09,4.83]},
{name:'stringa copy{str_with_len_N};/16',data:[1.10,1.34,1.29,4.08,7.81]},
{name:'stringa copy{str_with_len_N};/23',data:[1.12,1.32,1.31,3.99,8.12]},
{name:'stringa copy{str_with_len_N};/24',data:[16.1,16.7,15.9,18.6,7.86]},
{name:'stringa copy{str_with_len_N};/32',data:[16.0,16.4,17.4,18.5,7.82]},
{name:'stringa copy{str_with_len_N};/64',data:[16.3,16.4,16.0,18.6,7.90]},
{name:'stringa copy{str_with_len_N};/128',data:[16.1,16.5,16.0,18.5,7.78]},
{name:'stringa copy{str_with_len_N};/256',data:[16.1,16.4,16.0,18.7,8.03]},
{name:'stringa copy{str_with_len_N};/512',data:[16.0,16.4,16.0,18.6,7.91]},
{name:'stringa copy{str_with_len_N};/1024',data:[16.2,16.6,16.0,18.6,7.78]},
{name:'stringa copy{str_with_len_N};/2048',data:[16.2,16.7,16.0,18.5,7.80]},
{name:'stringa copy{str_with_len_N};/4096',data:[16.0,16.9,16.0,18.6,7.79]},
{name:'lstringa< 16 > copy{str_with_len_N};/15',data:[1.52,1.16,1.52,4.08,8.00]},
{name:'lstringa< 16 > copy{str_with_len_N};/16',data:[4.83,4.98,5.17,8.48,20.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/23',data:[4.81,5.05,5.12,8.50,88.9]},
{name:'lstringa< 16 > copy{str_with_len_N};/24',data:[25.0,24.6,77.9,78.6,88.3]},
{name:'lstringa< 16 > copy{str_with_len_N};/32',data:[25.1,24.4,83.5,83.2,92.9]},
{name:'lstringa< 16 > copy{str_with_len_N};/64',data:[27.4,26.2,84.6,84.0,96.1]},
{name:'lstringa< 16 > copy{str_with_len_N};/128',data:[27.1,27.6,84.6,87.1,97.2]},
{name:'lstringa< 16 > copy{str_with_len_N};/256',data:[28.1,27.8,85.7,90.7,130]},
{name:'lstringa< 16 > copy{str_with_len_N};/512',data:[30.7,31.0,87.1,89.3,116]},
{name:'lstringa< 16 > copy{str_with_len_N};/1024',data:[52.9,55.0,96.6,101,139]},
{name:'lstringa< 16 > copy{str_with_len_N};/2048',data:[67.6,64.4,125,125,178]},
{name:'lstringa< 16 > copy{str_with_len_N};/4096',data:[87.8,90.0,180,190,221]},
{name:'lstringa< 512 > copy{str_with_len_N};/15',data:[1.58,1.13,1.45,4.82,8.09]},
{name:'lstringa< 512 > copy{str_with_len_N};/16',data:[4.90,4.48,5.21,9.21,21.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/23',data:[4.83,4.49,5.18,9.42,20.4]},
{name:'lstringa< 512 > copy{str_with_len_N};/24',data:[4.78,4.10,5.21,9.49,20.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/32',data:[4.59,4.40,8.19,12.2,22.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/64',data:[6.15,5.64,8.21,12.2,23.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/128',data:[7.02,7.25,8.48,12.7,24.5]},
{name:'lstringa< 512 > copy{str_with_len_N};/256',data:[8.43,7.90,9.79,13.6,26.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/512',data:[11.5,10.4,11.2,15.4,28.5]},
{name:'lstringa< 512 > copy{str_with_len_N};/1024',data:[57.0,55.7,98.6,99.1,137]},
{name:'lstringa< 512 > copy{str_with_len_N};/2048',data:[65.8,66.5,124,127,174]},
{name:'lstringa< 512 > copy{str_with_len_N};/4096',data:[92.2,89.3,182,191,220]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs16" > < h4 > < a id = "bs94756718925776995960" href = "#bs94756718925776995960" > #< / a > Convert to int ' 1234567' < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L801" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 10);< / a > < span class = "tooltiptext code" > void ToIntStr10(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 10);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr для конвертации в число достаточно куска строки,
нет нужды в null терминированности. Ближайший аналог такого
поведения "std::from_chars", но он к сожалению очень ограничен
по возможностям. Здесь я попытался произвести тесты, близкие по
2026-01-21 11:59:17 +00:00
логике к работе 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.
2026-02-15 14:13:54 +00:00
Here, I attempted to run tests that are similar in logic to std::from_chars.< / span > < / span > < / td > < td class = "benchmarkresult" > 27.2< / td > < td class = "benchmarkresult" > 27.1< / td > < td class = "benchmarkresult" > 31.8< / td > < td class = "benchmarkresult" > 31.5< / td > < td class = "benchmarkresult" > 201< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L840" > std::string_view s = " 123456789" ; std::from_chars(s.data(), s.data() + s.size(), res, 10);< / a > < span class = "tooltiptext code" > void ToIntFromChars10(benchmark::State& state, const std::string_view& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = 0;
std::from_chars(s.data(), s.data() + s.size(), res, 10);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > from_chars требует точного указания основания счисления,
2026-01-21 11:59:17 +00:00
не допускает знаков плюс, пробелов, префиксов 0x и т.п.
from_chars requires an exact radix specification and does not allow plus
2026-02-15 14:13:54 +00:00
signs, spaces, 0x prefixes, etc.< / span > < / span > < / td > < td class = "benchmarkresult" > 13.5< / td > < td class = "benchmarkresult" > 12.1< / td > < td class = "benchmarkresult" > 13.3< / td > < td class = "benchmarkresult" > 11.9< / td > < td class = "benchmarkresult" > 2.16< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L868" > stringa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь для to_int заданы такие же ограничения - проверять переполнение,
2026-01-21 11:59:17 +00:00
десятичная система, без лидирующих пробелов и знака плюс
Here, to_int has the same restrictions: check for overflow,
2026-02-15 14:13:54 +00:00
decimal system, no leading spaces, and no plus sign.< / span > < / span > < / td > < td class = "benchmarkresult" > 9.58< / td > < td class = "benchmarkresult" > 8.79< / td > < td class = "benchmarkresult" > 13.4< / td > < td class = "benchmarkresult" > 16.5< / td > < td class = "benchmarkresult" > 61.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L868" > ssa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.54< / td > < td class = "benchmarkresult" > 8.08< / td > < td class = "benchmarkresult" > 9.66< / td > < td class = "benchmarkresult" > 15.2< / td > < td class = "benchmarkresult" > 49.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L868" > lstringa< 20> s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.49< / td > < td class = "benchmarkresult" > 8.74< / td > < td class = "benchmarkresult" > 13.3< / td > < td class = "benchmarkresult" > 15.2< / td > < td class = "benchmarkresult" > 49.4< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n v e r t t o i n t \ ' 1 2 3 4 5 6 7 \ ' ' ] = { i d : ' b s 1 6 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);',data:[27.2,27.1,31.8,31.5,201]},
{name:'std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);',data:[13.5,12.1,13.3,11.9,2.16]},
{name:'stringa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.58,8.79,13.4,16.5,61.4]},
{name:'ssa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.54,8.08,9.66,15.2,49.4]},
{name:'lstringa< 20 > s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.49,8.74,13.3,15.2,49.4]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs17" > < h4 > < a id = "bs182426078870126042750" href = "#bs182426078870126042750" > #< / a > Convert to unsigned ' abcDef' < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L814" > std::string s = " abcDef" ; int res = std::strtol(s.c_str(), 0, 16);< / a > < span class = "tooltiptext code" > void ToIntStr16(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 16);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Всё то же, только для 16р ично й системы
2026-02-15 14:13:54 +00:00
Everything is the same, only for the hexadecimal system< / span > < / span > < / td > < td class = "benchmarkresult" > 24.8< / td > < td class = "benchmarkresult" > 23.4< / td > < td class = "benchmarkresult" > 33.5< / td > < td class = "benchmarkresult" > 34.9< / td > < td class = "benchmarkresult" > 146< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L854" > std::string_view s = " abcDef" ; std::from_chars(s.data(), s.data() + s.size(), res, 16);< / a > < span class = "tooltiptext code" > void ToIntFromChars16(benchmark::State& state, const std::string_view& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = 0;
std::from_chars(s.data(), s.data() + s.size(), res, 16);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.45< / td > < td class = "benchmarkresult" > 8.70< / td > < td class = "benchmarkresult" > 8.10< / td > < td class = "benchmarkresult" > 9.00< / td > < td class = "benchmarkresult" > 57.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L883" > stringa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.81< / td > < td class = "benchmarkresult" > 8.52< / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 14.4< / td > < td class = "benchmarkresult" > 60.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L883" > ssa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.67< / td > < td class = "benchmarkresult" > 6.64< / td > < td class = "benchmarkresult" > 7.43< / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 45.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L883" > lstringa< 20> s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.71< / td > < td class = "benchmarkresult" > 8.72< / td > < td class = "benchmarkresult" > 11.8< / td > < td class = "benchmarkresult" > 12.6< / td > < td class = "benchmarkresult" > 46.3< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n v e r t t o u n s i g n e d \ ' a b c D e f \ ' ' ] = { i d : ' b s 1 7 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);',data:[24.8,23.4,33.5,34.9,146]},
{name:'std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);',data:[9.45,8.70,8.10,9.00,57.3]},
{name:'stringa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.81,8.52,12.5,14.4,60.0]},
{name:'ssa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.67,6.64,7.43,13.1,45.9]},
{name:'lstringa< 20 > s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.71,8.72,11.8,12.6,46.3]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs18" > < h4 > < a id = "bs52606100125109966680" href = "#bs52606100125109966680" > #< / a > Convert to int ' 1234567' < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L827" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 0);< / a > < span class = "tooltiptext code" > void ToIntStr0(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 0);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А здесь уже парсинг произвольного числа.
2026-02-15 14:13:54 +00:00
And here we have parsing of an arbitrary number.< / span > < / span > < / td > < td class = "benchmarkresult" > 30.3< / td > < td class = "benchmarkresult" > 29.0< / td > < td class = "benchmarkresult" > 43.8< / td > < td class = "benchmarkresult" > 47.5< / td > < td class = "benchmarkresult" > 208< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L898" > stringa s = " 123456789" ; int res = s.to_int< int>; // Check overflow< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr0(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 11.3< / td > < td class = "benchmarkresult" > 14.6< / td > < td class = "benchmarkresult" > 16.5< / td > < td class = "benchmarkresult" > 22.1< / td > < td class = "benchmarkresult" > 58.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L913" > ssa s = " 123456789" ; int res = s.to_int< int, false>; // No check overflow< / a > < span class = "tooltiptext code" > void ToIntNoOverflow(benchmark::State& state, ssa t, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t.to_int< int, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 10.9< / td > < td class = "benchmarkresult" > 12.9< / td > < td class = "benchmarkresult" > 18.9< / td > < td class = "benchmarkresult" > 45.9< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n v e r t t o i n t \ ' 1 2 3 4 5 6 7 \ ' ' ] = { i d : ' b s 1 8 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);',data:[30.3,29.0,43.8,47.5,208]},
{name:'stringa s = " 123456789"; int res = s.to_int< int > ; // Check overflow',data:[11.3,14.6,16.5,22.1,58.9]},
{name:'ssa s = " 123456789"; int res = s.to_int< int , false > ; // No check overflow',data:[13.1,10.9,12.9,18.9,45.9]}
2025-11-26 19:15:50 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs19" > < h4 > < a id = "bs182348477702821075660" href = "#bs182348477702821075660" > #< / a > Convert to double ' 1234.567e10' < / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L943" > std::string s = " 1234.567e10" ; double res = std::strtod(s.c_str(), nullptr);< / a > < span class = "tooltiptext code" > void ToDoubleStr(benchmark::State& state, const std::string& s, double c) {
2025-11-26 19:15:50 +00:00
for (auto _: state) {
char* ptr = nullptr;
double res = std::strtod(s.c_str(), & ptr);
if (ptr == s.c_str()) {
state.SkipWithError(" not equal" );
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 65.5< / td > < td class = "benchmarkresult" > 65.1< / td > < td class = "benchmarkresult" > 103< / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 578< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L960" > std::string_view s = " 1234.567e10" ; std::from_chars(s.data(), s.data() + s.size(), res);< / a > < span class = "tooltiptext code" > void ToDoubleFromChars(benchmark::State& state, const std::string_view& s, double c) {
2025-11-26 19:15:50 +00:00
for (auto _: state) {
double res = 0;
if (std::from_chars(s.data(), s.data() + s.size(), res).ec != std::errc{}) {
state.SkipWithError(" not equal" );
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 25.0< / td > < td class = "benchmarkresult" > 59.5< / td > < td class = "benchmarkresult" > 84.1< / td > < td class = "benchmarkresult" > 273< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L976" > ssa s = " 1234.567e10" ; double res = *s.to_double()< / a > < span class = "tooltiptext code" > template< typename T>
2025-11-26 19:15:50 +00:00
void ToDoubleSimStr(benchmark::State& state, T t, double c) {
for (auto _: state) {
auto r = t.template to_double< false>();
if (!r) {
state.SkipWithError(" not equal" );
}
double res = *r;
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 26.4< / td > < td class = "benchmarkresult" > 24.4< / td > < td class = "benchmarkresult" > 35.5< / td > < td class = "benchmarkresult" > 37.8< / td > < td class = "benchmarkresult" > 93.8< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C o n v e r t t o d o u b l e \ ' 1 2 3 4 . 5 6 7 e 1 0 \ ' ' ] = { i d : ' b s 1 9 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);',data:[65.5,65.1,103,104,578]},
{name:'std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);',data:[24.2,25.0,59.5,84.1,273]},
{name:'ssa s = "1234.567e10"; double res = *s.to_double()',data:[26.4,24.4,35.5,37.8,93.8]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs20" > < h4 > < a id = "bs96505608161678391610" href = "#bs96505608161678391610" > #< / a > Append const literal of 16 bytes 64 times, 1024 total length< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1000" > std::stringstream str; ... str < < " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStreamConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
std::stringstream str;
for (size_t c = 0; c < 64; c++) {
str < < TEXT_16;
}
result = str.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(str);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1396< / td > < td class = "benchmarkresult" > 1375< / td > < td class = "benchmarkresult" > 4726< / td > < td class = "benchmarkresult" > 5627< / td > < td class = "benchmarkresult" > 15958< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1019" > std::string str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStdStringConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 375< / td > < td class = "benchmarkresult" > 350< / td > < td class = "benchmarkresult" > 1064< / td > < td class = "benchmarkresult" > 1313< / td > < td class = "benchmarkresult" > 1434< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1035" > lstringa< 8> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 369< / td > < td class = "benchmarkresult" > 338< / td > < td class = "benchmarkresult" > 793< / td > < td class = "benchmarkresult" > 942< / td > < td class = "benchmarkresult" > 1411< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1035" > lstringa< 128> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Чем больше внутренний буфер, тем меньше раз требуется
2026-01-21 11:59:17 +00:00
аллокация, тем быстрее результат.
The larger the internal buffer, the fewer allocations are
2026-02-15 14:13:54 +00:00
required, and the faster the result.< / span > < / span > < / td > < td class = "benchmarkresult" > 233< / td > < td class = "benchmarkresult" > 245< / td > < td class = "benchmarkresult" > 393< / td > < td class = "benchmarkresult" > 519< / td > < td class = "benchmarkresult" > 920< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1035" > lstringa< 512> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 238< / td > < td class = "benchmarkresult" > 217< / td > < td class = "benchmarkresult" > 259< / td > < td class = "benchmarkresult" > 370< / td > < td class = "benchmarkresult" > 638< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1035" > lstringa< 1024> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 163< / td > < td class = "benchmarkresult" > 141< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 288< / td > < td class = "benchmarkresult" > 509< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d c o n s t l i t e r a l o f 1 6 b y t e s 6 4 t i m e s , 1 0 2 4 t o t a l l e n g t h ' ] = { i d : ' b s 2 0 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::stringstream str; ... str < < "abbaabbaabbaabba";',data:[1396,1375,4726,5627,15958]},
{name:'std::string str; ... str += "abbaabbaabbaabba";',data:[375,350,1064,1313,1434]},
{name:'lstringa< 8 > str; ... str += "abbaabbaabbaabba";',data:[369,338,793,942,1411]},
{name:'lstringa< 128 > str; ... str += "abbaabbaabbaabba";',data:[233,245,393,519,920]},
{name:'lstringa< 512 > str; ... str += "abbaabbaabbaabba";',data:[238,217,259,370,638]},
{name:'lstringa< 1024 > str; ... str += "abbaabbaabbaabba";',data:[163,141,134,288,509]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs21" > < h4 > < a id = "bs36931044816721597850" href = "#bs36931044816721597850" > #< / a > Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1060" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStreamStrConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 32; c++) {
s < < s1 < < TEXT_16;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1370< / td > < td class = "benchmarkresult" > 1370< / td > < td class = "benchmarkresult" > 4556< / td > < td class = "benchmarkresult" > 6205< / td > < td class = "benchmarkresult" > 16329< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1080" > std::string str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStdStrStrConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string p1 = TEXT_16;
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1302< / td > < td class = "benchmarkresult" > 1238< / td > < td class = "benchmarkresult" > 3712< / td > < td class = "benchmarkresult" > 3832< / td > < td class = "benchmarkresult" > 4574< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1098" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 415< / td > < td class = "benchmarkresult" > 405< / td > < td class = "benchmarkresult" > 716< / td > < td class = "benchmarkresult" > 841< / td > < td class = "benchmarkresult" > 1521< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1098" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 339< / td > < td class = "benchmarkresult" > 339< / td > < td class = "benchmarkresult" > 444< / td > < td class = "benchmarkresult" > 525< / td > < td class = "benchmarkresult" > 1206< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1098" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 265< / td > < td class = "benchmarkresult" > 315< / td > < td class = "benchmarkresult" > 286< / td > < td class = "benchmarkresult" > 391< / td > < td class = "benchmarkresult" > 916< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1098" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 205< / td > < td class = "benchmarkresult" > 250< / td > < td class = "benchmarkresult" > 183< / td > < td class = "benchmarkresult" > 286< / td > < td class = "benchmarkresult" > 813< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d s t r i n g o f 1 6 b y t e s a n d c o n s t l i t e r a l o f 1 6 b y t e s 3 2 t i m e s , 1 0 2 4 t o t a l l e n g t h ' ] = { i d : ' b s 2 1 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; ' , data: [ 1370 , 1370 , 4556 , 6205 , 16329 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba";',data:[1302,1238,3712,3832,4574]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba";',data:[415,405,716,841,1521]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba";',data:[339,339,444,525,1206]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba";',data:[265,315,286,391,916]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba";',data:[205,250,183,286,813]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs22" > < h4 > < a id = "bs8293767858383349360" href = "#bs8293767858383349360" > #< / a > Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1126" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > void AppendStreamStrConstLiteralBig(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 2048; c++) {
s < < s1 < < TEXT_16;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 123086< / td > < td class = "benchmarkresult" > 125525< / td > < td class = "benchmarkresult" > 217525< / td > < td class = "benchmarkresult" > 285336< / td > < td class = "benchmarkresult" > 833815< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1146" > std::string str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > void AppendStdStrStrConstLiteralBig(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string p1 = TEXT_16;
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 73997< / td > < td class = "benchmarkresult" > 73243< / td > < td class = "benchmarkresult" > 191801< / td > < td class = "benchmarkresult" > 192976< / td > < td class = "benchmarkresult" > 241478< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1164" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 46351< / td > < td class = "benchmarkresult" > 49189< / td > < td class = "benchmarkresult" > 19975< / td > < td class = "benchmarkresult" > 25665< / td > < td class = "benchmarkresult" > 57002< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1164" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27970< / td > < td class = "benchmarkresult" > 26787< / td > < td class = "benchmarkresult" > 16815< / td > < td class = "benchmarkresult" > 22282< / td > < td class = "benchmarkresult" > 56617< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1164" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 19316< / td > < td class = "benchmarkresult" > 20894< / td > < td class = "benchmarkresult" > 16248< / td > < td class = "benchmarkresult" > 21972< / td > < td class = "benchmarkresult" > 53906< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1164" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15641< / td > < td class = "benchmarkresult" > 16956< / td > < td class = "benchmarkresult" > 16122< / td > < td class = "benchmarkresult" > 22145< / td > < td class = "benchmarkresult" > 55763< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d s t r i n g o f 1 6 b y t e s a n d c o n s t l i t e r a l o f 1 6 b y t e s 2 0 4 8 t i m e s , 6 5 5 3 6 t o t a l l e n g t h ' ] = { i d : ' b s 2 2 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; 2048 times ' , data: [ 123086 , 125525 , 217525 , 285336 , 833815 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[73997,73243,191801,192976,241478]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[46351,49189,19975,25665,57002]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[27970,26787,16815,22282,56617]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[19316,20894,16248,21972,53906]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[15641,16956,16122,22145,55763]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs23" > < h4 > < a id = "bs66949588770596833730" href = "#bs66949588770596833730" > #< / a > Append 2 string of 16 bytes 32 times, 1024 total length< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1191" > std::stringstream str; ... str < < str_var1 < < str_var2;< / a > < span class = "tooltiptext code" > void AppendStream2String(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
std::string s2 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 32; c++) {
s < < s1 < < s2;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1388< / td > < td class = "benchmarkresult" > 1440< / td > < td class = "benchmarkresult" > 4414< / td > < td class = "benchmarkresult" > 5300< / td > < td class = "benchmarkresult" > 15927< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1213" > std::string str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > void AppendStdStr2String(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
std::string s2 = TEXT_16;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1441< / td > < td class = "benchmarkresult" > 1374< / td > < td class = "benchmarkresult" > 3894< / td > < td class = "benchmarkresult" > 3964< / td > < td class = "benchmarkresult" > 4954< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1234" > lstringa< 16> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 500< / td > < td class = "benchmarkresult" > 476< / td > < td class = "benchmarkresult" > 791< / td > < td class = "benchmarkresult" > 909< / td > < td class = "benchmarkresult" > 1852< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1234" > lstringa< 128> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 401< / td > < td class = "benchmarkresult" > 416< / td > < td class = "benchmarkresult" > 523< / td > < td class = "benchmarkresult" > 624< / td > < td class = "benchmarkresult" > 1497< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1234" > lstringa< 512> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 370< / td > < td class = "benchmarkresult" > 368< / td > < td class = "benchmarkresult" > 394< / td > < td class = "benchmarkresult" > 476< / td > < td class = "benchmarkresult" > 1196< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1234" > lstringa< 1024> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 302< / td > < td class = "benchmarkresult" > 316< / td > < td class = "benchmarkresult" > 288< / td > < td class = "benchmarkresult" > 367< / td > < td class = "benchmarkresult" > 1089< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d 2 s t r i n g o f 1 6 b y t e s 3 2 t i m e s , 1 0 2 4 t o t a l l e n g t h ' ] = { i d : ' b s 2 3 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::stringstream str; ... str < < str_var1 < < str_var2 ; ' , data: [ 1388 , 1440 , 4414 , 5300 , 15927 ] } ,
{name:'std::string str; ... str += str_var1 + str_var2;',data:[1441,1374,3894,3964,4954]},
{name:'lstringa< 16 > str; ... str += str_var1 + str_var2;',data:[500,476,791,909,1852]},
{name:'lstringa< 128 > str; ... str += str_var1 + str_var2;',data:[401,416,523,624,1497]},
{name:'lstringa< 512 > str; ... str += str_var1 + str_var2;',data:[370,368,394,476,1196]},
{name:'lstringa< 1024 > str; ... str += str_var1 + str_var2;',data:[302,316,288,367,1089]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs24" > < h4 > < a id = "bs130432147582115154460" href = "#bs130432147582115154460" > #< / a > Append text, number, text< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1263" > std::stringstream str; str < < " test = " < < k < < " times" ;< / a > < span class = "tooltiptext code" > void AppendStreamStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::stringstream t;
t < < " test = " < < k < < " times" ;
std::string result = t.str();
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3023< / td > < td class = "benchmarkresult" > 3250< / td > < td class = "benchmarkresult" > 11096< / td > < td class = "benchmarkresult" > 11879< / td > < td class = "benchmarkresult" > 25783< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1281" > std::string str = " test = " + std::to_string(k) + " times" ;< / a > < span class = "tooltiptext code" > void AppendStdStringStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::string result = " test = " + std::to_string(k) + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 443< / td > < td class = "benchmarkresult" > 428< / td > < td class = "benchmarkresult" > 1066< / td > < td class = "benchmarkresult" > 1691< / td > < td class = "benchmarkresult" > 3681< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1297" > char buf[100]; sprintf(buf, " test = %u times" , k); std::string str = buf;< / a > < span class = "tooltiptext code" > void AppendSprintfStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
char buf[100];
std::sprintf(buf, " test = %u times" , k);
std::string result = buf;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1337< / td > < td class = "benchmarkresult" > 1489< / td > < td class = "benchmarkresult" > 2788< / td > < td class = "benchmarkresult" > 2823< / td > < td class = "benchmarkresult" > 10716< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1315" > std::string str = std::format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > void AppendFormatStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::string result = std::format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1174< / td > < td class = "benchmarkresult" > 1458< / td > < td class = "benchmarkresult" > 1845< / td > < td class = "benchmarkresult" > 2332< / td > < td class = "benchmarkresult" > 5711< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1331" > lstringa< 8> str; str.format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStrF(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result;
result.format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr format с первого раза не помещается в такую строку без аллокации.
In simstr format, the first time it doesn't fit into such a
2026-02-15 14:13:54 +00:00
string without allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 1348< / td > < td class = "benchmarkresult" > 1574< / td > < td class = "benchmarkresult" > 2035< / td > < td class = "benchmarkresult" > 2730< / td > < td class = "benchmarkresult" > 8447< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1331" > lstringa< 32> str; str.format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStrF(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result;
result.format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А в такую помещается. Используйте сразу буфера подходящего размера.
2026-02-15 14:13:54 +00:00
And it fits in this one. Use buffers of the appropriate size right away.< / span > < / span > < / td > < td class = "benchmarkresult" > 984< / td > < td class = "benchmarkresult" > 1098< / td > < td class = "benchmarkresult" > 965< / td > < td class = "benchmarkresult" > 1530< / td > < td class = "benchmarkresult" > 7294< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1349" > lstringa< 8> str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Результат не помещается в SSO, возникает аллокация.
2026-02-15 14:13:54 +00:00
The result does not fit into SSO, an allocation occurs.< / span > < / span > < / td > < td class = "benchmarkresult" > 286< / td > < td class = "benchmarkresult" > 303< / td > < td class = "benchmarkresult" > 821< / td > < td class = "benchmarkresult" > 938< / td > < td class = "benchmarkresult" > 1418< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1349" > lstringa< 32> str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А здесь и ниже - результат укладывается в SSO.
2026-01-21 11:59:17 +00:00
Ещё раз - используйте сразу буфера подходящего размера.
And here and below, the result fits within SSO.
2026-02-15 14:13:54 +00:00
Once again, use appropriately sized buffers from the start.< / span > < / span > < / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 148< / td > < td class = "benchmarkresult" > 142< / td > < td class = "benchmarkresult" > 171< / td > < td class = "benchmarkresult" > 572< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1349" > stringa str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Под WASM размер SSO 15 символов, что явно не хватает для размещения
2026-01-21 11:59:17 +00:00
результата, отсюда и такое время.
Under WASM, the SSO size is 15 characters, which is clearly not
2026-02-15 14:13:54 +00:00
enough to accommodate the result, hence the long time.< / span > < / span > < / td > < td class = "benchmarkresult" > 133< / td > < td class = "benchmarkresult" > 137< / td > < td class = "benchmarkresult" > 122< / td > < td class = "benchmarkresult" > 174< / td > < td class = "benchmarkresult" > 1197< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d t e x t , n u m b e r , t e x t ' ] = { i d : ' b s 2 4 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::stringstream str; str < < "test = " < < k < < " times " ; ' , data: [ 3023 , 3250 , 11096 , 11879 , 25783 ] } ,
{name:'std::string str = "test = " + std::to_string(k) + " times";',data:[443,428,1066,1691,3681]},
{name:'char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;',data:[1337,1489,2788,2823,10716]},
{name:'std::string str = std::format("test = {} times", k);',data:[1174,1458,1845,2332,5711]},
{name:'lstringa< 8 > str; str.format("test = {} times", k);',data:[1348,1574,2035,2730,8447]},
{name:'lstringa< 32 > str; str.format("test = {} times", k);',data:[984,1098,965,1530,7294]},
{name:'lstringa< 8 > str = "test = " + k + " times";',data:[286,303,821,938,1418]},
{name:'lstringa< 32 > str = "test = " + k + " times";',data:[129,148,142,171,572]},
{name:'stringa str = "test = " + k + " times";',data:[133,137,122,174,1197]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs25" > < h4 > < a id = "bs7106975351756760120" href = "#bs7106975351756760120" > #< / a > Split text and convert to int< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1379" > std::string::find + substr + std::strtol< / a > < span class = "tooltiptext code" > void SplitConvertIntStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
for (size_t start = 0; start < numbers.length(); ) {
int delim = numbers.find(" -!-" , 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 + 3;
}
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 259< / td > < td class = "benchmarkresult" > 279< / td > < td class = "benchmarkresult" > 544< / td > < td class = "benchmarkresult" > 545< / td > < td class = "benchmarkresult" > 1443< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1403" > ssa::splitter + ssa::as_int< / a > < span class = "tooltiptext code" > void SplitConvertIntSimStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
stra numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
for (auto splitter = numbers.splitter(" -!-" ); !splitter.is_done();) {
total += splitter.next().as_int< int>();
}
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 165< / td > < td class = "benchmarkresult" > 298< / td > < td class = "benchmarkresult" > 595< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1420" > ssa::splitf + functor< / a > < span class = "tooltiptext code" > void SplitConvertIntSplitf(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
stra numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
numbers.splitf< void>(" -!-" , [& ](ssa& part){total += part.as_int< int>();});
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 210< / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 214< / td > < td class = "benchmarkresult" > 853< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' S p l i t t e x t a n d c o n v e r t t o i n t ' ] = { i d : ' b s 2 5 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'std::string::find + substr + std::strtol',data:[259,279,544,545,1443]},
{name:'ssa::splitter + ssa::as_int',data:[157,134,165,298,595]},
{name:'ssa::splitf + functor',data:[210,139,190,214,853]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs26" > < h4 > < a id = "bs151373809886162287550" href = "#bs151373809886162287550" > #< / a > Replace symbols in text ~400 symbols< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1441" > Naive (and wrong) replace symbols with std::string find + replace< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' & ' , " & amp;" },
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" }
};
auto repl_all = [](std::string& str, char s, std::string_view repl) {
size_t start_pos = 0;
while((start_pos = str.find(s, start_pos)) != std::string::npos) {
str.replace(start_pos, 1, repl);
start_pos += repl.length();
}
};
for (auto _: state) {
std::string result{source};
for (const auto& r : repl) {
repl_all(result, r.first, r.second);
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Это наивная реализация, которая неверно отработает на
таких заменах, как 'a'->'b' и 'b'->'a'. Н о если замены не конфликтуют,
2026-01-21 11:59:17 +00:00
то работает быстро.
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,
2026-02-15 14:13:54 +00:00
it works quickly.< / span > < / span > < / td > < td class = "benchmarkresult" > 881< / td > < td class = "benchmarkresult" > 1153< / td > < td class = "benchmarkresult" > 1093< / td > < td class = "benchmarkresult" > 1191< / td > < td class = "benchmarkresult" > 4959< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1495" > replace symbols with std::string find_first_of + replace< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
std::string result{source};
std::string pattern;
for (const auto& r : repl) {
pattern += r.first;
}
size_t start_pos = 0;
while((start_pos = result.find_first_of(pattern, start_pos)) != std::string::npos) {
size_t idx = pattern.find(result[start_pos]);
result.replace(start_pos, 1, repl[idx].second);
start_pos += repl[idx].second.length();
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Дальше уже правильные реализации, не зависящие от конфликтующих замен.
Further, there are correct implementations that do not depend on
2026-02-15 14:13:54 +00:00
conflicting replacements.< / span > < / span > < / td > < td class = "benchmarkresult" > 2480< / td > < td class = "benchmarkresult" > 2567< / td > < td class = "benchmarkresult" > 2049< / td > < td class = "benchmarkresult" > 2209< / td > < td class = "benchmarkresult" > 9947< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1549" > replace symbols with std::string_view find_first_of + copy< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
const std::string_view repl_from = " -< >' \" & " ;
const std::string_view repl_to[] = {" " , " & lt;" , " & gt;" , " & #39;" , " & quot;" , " & amp;" };
for (auto _: state) {
std::string result;
for (size_t start = 0; start < source.size();) {
size_t idx = source.find_first_of(repl_from, start);
if (idx == std::string::npos) {
result += source.substr(start);
break;
}
if (idx > start) {
result += source.substr(start, idx - start);
}
size_t what = repl_from.find(source[idx]);
result += repl_to[what];
start = idx + 1;
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1093< / td > < td class = "benchmarkresult" > 959< / td > < td class = "benchmarkresult" > 2329< / td > < td class = "benchmarkresult" > 2598< / td > < td class = "benchmarkresult" > 4617< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1602" > replace runtime symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1265< / td > < td class = "benchmarkresult" > 1461< / td > < td class = "benchmarkresult" > 1454< / td > < td class = "benchmarkresult" > 1546< / td > < td class = "benchmarkresult" > 4256< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1602" > replace runtime symbols with simstr and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1114< / td > < td class = "benchmarkresult" > 1209< / td > < td class = "benchmarkresult" > 1257< / td > < td class = "benchmarkresult" > 1349< / td > < td class = "benchmarkresult" > 3810< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1649" > replace const symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1098< / td > < td class = "benchmarkresult" > 1207< / td > < td class = "benchmarkresult" > 1136< / td > < td class = "benchmarkresult" > 1272< / td > < td class = "benchmarkresult" > 3231< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1649" > replace const symbols with string expressions and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 837< / td > < td class = "benchmarkresult" > 854< / td > < td class = "benchmarkresult" > 1188< / td > < td class = "benchmarkresult" > 1283< / td > < td class = "benchmarkresult" > 3050< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' R e p l a c e s y m b o l s i n t e x t ~ 4 0 0 s y m b o l s ' ] = { i d : ' b s 2 6 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Naive (and wrong) replace symbols with std::string find + replace',data:[881,1153,1093,1191,4959]},
{name:'replace symbols with std::string find_first_of + replace',data:[2480,2567,2049,2209,9947]},
{name:'replace symbols with std::string_view find_first_of + copy',data:[1093,959,2329,2598,4617]},
{name:'replace runtime symbols with string expressions and without remembering all search results',data:[1265,1461,1454,1546,4256]},
{name:'replace runtime symbols with simstr and memorization of all search results',data:[1114,1209,1257,1349,3810]},
{name:'replace const symbols with string expressions and without remembering all search results',data:[1098,1207,1136,1272,3231]},
{name:'replace const symbols with string expressions and memorization of all search results',data:[837,854,1188,1283,3050]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs27" > < h4 > < a id = "bs96756339547767401190" href = "#bs96756339547767401190" > #< / a > Replace symbols in text ~40 symbols< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1703" > Short Naive (and wrong) replace symbols with std::string find + replace< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' & ' , " & amp;" },
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" }
};
auto repl_all = [](std::string& str, char s, std::string_view repl) {
size_t start_pos = 0;
while((start_pos = str.find(s, start_pos)) != std::string::npos) {
str.replace(start_pos, 1, repl);
start_pos += repl.length();
}
};
for (auto _: state) {
std::string result{source};
for (const auto& r : repl) {
repl_all(result, r.first, r.second);
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 162< / td > < td class = "benchmarkresult" > 162< / td > < td class = "benchmarkresult" > 307< / td > < td class = "benchmarkresult" > 332< / td > < td class = "benchmarkresult" > 889< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1743" > Short replace symbols with std::string find_first_of + replace< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
std::string result{source};
std::string pattern;
for (const auto& r : repl) {
pattern += r.first;
}
size_t start_pos = 0;
while((start_pos = result.find_first_of(pattern, start_pos)) != std::string::npos) {
size_t idx = pattern.find(result[start_pos]);
result.replace(start_pos, 1, repl[idx].second);
start_pos += repl[idx].second.length();
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 321< / td > < td class = "benchmarkresult" > 333< / td > < td class = "benchmarkresult" > 361< / td > < td class = "benchmarkresult" > 419< / td > < td class = "benchmarkresult" > 1379< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1783" > Short replace symbols with std::string_view find_first_of + copy< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
const std::string_view repl_from = " -< >' \" & " ;
const std::string_view repl_to[] = {" " , " & lt;" , " & gt;" , " & #39;" , " & quot;" , " & amp;" };
for (auto _: state) {
std::string result;
for (size_t start = 0; start < source.size();) {
size_t idx = source.find_first_of(repl_from, start);
if (idx == std::string::npos) {
result += source.substr(start);
break;
}
if (idx > start) {
result += source.substr(start, idx - start);
}
size_t what = repl_from.find_first_of(source[idx]);
result += repl_to[what];
start = idx + 1;
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 159< / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 315< / td > < td class = "benchmarkresult" > 344< / td > < td class = "benchmarkresult" > 804< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1822" > Short replace runtime symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 185< / td > < td class = "benchmarkresult" > 242< / td > < td class = "benchmarkresult" > 299< / td > < td class = "benchmarkresult" > 645< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1822" > Short replace runtime symbols with simstr and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 293< / td > < td class = "benchmarkresult" > 209< / td > < td class = "benchmarkresult" > 338< / td > < td class = "benchmarkresult" > 380< / td > < td class = "benchmarkresult" > 770< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1855" > Short replace const symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 130< / td > < td class = "benchmarkresult" > 147< / td > < td class = "benchmarkresult" > 195< / td > < td class = "benchmarkresult" > 243< / td > < td class = "benchmarkresult" > 438< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1855" > Short replace const symbols with string expressions and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 309< / td > < td class = "benchmarkresult" > 344< / td > < td class = "benchmarkresult" > 577< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' R e p l a c e s y m b o l s i n t e x t ~ 4 0 s y m b o l s ' ] = { i d : ' b s 2 7 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Short Naive (and wrong) replace symbols with std::string find + replace',data:[162,162,307,332,889]},
{name:'Short replace symbols with std::string find_first_of + replace',data:[321,333,361,419,1379]},
{name:'Short replace symbols with std::string_view find_first_of + copy',data:[159,168,315,344,804]},
{name:'Short replace runtime symbols with string expressions and without remembering all search results',data:[181,185,242,299,645]},
{name:'Short replace runtime symbols with simstr and memorization of all search results',data:[293,209,338,380,770]},
{name:'Short replace const symbols with string expressions and without remembering all search results',data:[130,147,195,243,438]},
{name:'Short replace const symbols with string expressions and memorization of all search results',data:[139,134,309,344,577]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs28" > < h4 > < a id = "bs77745698784557935900" href = "#bs77745698784557935900" > #< / a > Replace All Str To Longer Size< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1894" > replace bb to ---- in std::string|64< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 159< / td > < td class = "benchmarkresult" > 216< / td > < td class = "benchmarkresult" > 239< / td > < td class = "benchmarkresult" > 776< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1894" > replace bb to ---- in std::string|256< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 553< / td > < td class = "benchmarkresult" > 502< / td > < td class = "benchmarkresult" > 734< / td > < td class = "benchmarkresult" > 791< / td > < td class = "benchmarkresult" > 2406< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1894" > replace bb to ---- in std::string|512< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1093< / td > < td class = "benchmarkresult" > 995< / td > < td class = "benchmarkresult" > 1372< / td > < td class = "benchmarkresult" > 1460< / td > < td class = "benchmarkresult" > 4112< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1894" > replace bb to ---- in std::string|1024< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2427< / td > < td class = "benchmarkresult" > 2262< / td > < td class = "benchmarkresult" > 2999< / td > < td class = "benchmarkresult" > 3181< / td > < td class = "benchmarkresult" > 9118< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1894" > replace bb to ---- in std::string|2048< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5988< / td > < td class = "benchmarkresult" > 6071< / td > < td class = "benchmarkresult" > 7578< / td > < td class = "benchmarkresult" > 7842< / td > < td class = "benchmarkresult" > 19199< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1928" > replace bb to ---- in lstringa< 8>|64< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 138< / td > < td class = "benchmarkresult" > 214< / td > < td class = "benchmarkresult" > 225< / td > < td class = "benchmarkresult" > 620< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1928" > replace bb to ---- in lstringa< 8>|256< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 433< / td > < td class = "benchmarkresult" > 475< / td > < td class = "benchmarkresult" > 605< / td > < td class = "benchmarkresult" > 653< / td > < td class = "benchmarkresult" > 1900< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1928" > replace bb to ---- in lstringa< 8>|512< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 786< / td > < td class = "benchmarkresult" > 893< / td > < td class = "benchmarkresult" > 1028< / td > < td class = "benchmarkresult" > 1086< / td > < td class = "benchmarkresult" > 3505< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1928" > replace bb to ---- in lstringa< 8>|1024< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1611< / td > < td class = "benchmarkresult" > 1660< / td > < td class = "benchmarkresult" > 1795< / td > < td class = "benchmarkresult" > 2002< / td > < td class = "benchmarkresult" > 6338< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1928" > replace bb to ---- in lstringa< 8>|2048< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3063< / td > < td class = "benchmarkresult" > 3247< / td > < td class = "benchmarkresult" > 3547< / td > < td class = "benchmarkresult" > 3792< / td > < td class = "benchmarkresult" > 12720< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1951" > replace bb to ---- by init stringa|64< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
2026-02-14 10:09:54 +00:00
stringa result = e_repl(big_source, " bb" , " ----" );
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 91.6< / td > < td class = "benchmarkresult" > 84.8< / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 195< / td > < td class = "benchmarkresult" > 379< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1951" > replace bb to ---- by init stringa|256< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
2026-02-14 10:09:54 +00:00
stringa result = e_repl(big_source, " bb" , " ----" );
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 309< / td > < td class = "benchmarkresult" > 282< / td > < td class = "benchmarkresult" > 362< / td > < td class = "benchmarkresult" > 461< / td > < td class = "benchmarkresult" > 1126< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1951" > replace bb to ---- by init stringa|512< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
2026-02-14 10:09:54 +00:00
stringa result = e_repl(big_source, " bb" , " ----" );
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 700< / td > < td class = "benchmarkresult" > 674< / td > < td class = "benchmarkresult" > 824< / td > < td class = "benchmarkresult" > 1061< / td > < td class = "benchmarkresult" > 2808< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1951" > replace bb to ---- by init stringa|1024< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
2026-02-14 10:09:54 +00:00
stringa result = e_repl(big_source, " bb" , " ----" );
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1592< / td > < td class = "benchmarkresult" > 1535< / td > < td class = "benchmarkresult" > 1578< / td > < td class = "benchmarkresult" > 2174< / td > < td class = "benchmarkresult" > 5776< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1951" > replace bb to ---- by init stringa|2048< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
2026-02-14 10:09:54 +00:00
stringa result = e_repl(big_source, " bb" , " ----" );
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3230< / td > < td class = "benchmarkresult" > 3000< / td > < td class = "benchmarkresult" > 3172< / td > < td class = "benchmarkresult" > 4494< / td > < td class = "benchmarkresult" > 12197< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' R e p l a c e A l l S t r T o L o n g e r S i z e ' ] = { i d : ' b s 2 8 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'replace bb to ---- in std::string|64',data:[153,159,216,239,776]},
{name:'replace bb to ---- in std::string|256',data:[553,502,734,791,2406]},
{name:'replace bb to ---- in std::string|512',data:[1093,995,1372,1460,4112]},
{name:'replace bb to ---- in std::string|1024',data:[2427,2262,2999,3181,9118]},
{name:'replace bb to ---- in std::string|2048',data:[5988,6071,7578,7842,19199]},
{name:'replace bb to ---- in lstringa< 8 > |64',data:[129,138,214,225,620]},
{name:'replace bb to ---- in lstringa< 8 > |256',data:[433,475,605,653,1900]},
{name:'replace bb to ---- in lstringa< 8 > |512',data:[786,893,1028,1086,3505]},
{name:'replace bb to ---- in lstringa< 8 > |1024',data:[1611,1660,1795,2002,6338]},
{name:'replace bb to ---- in lstringa< 8 > |2048',data:[3063,3247,3547,3792,12720]},
{name:'replace bb to ---- by init stringa|64',data:[91.6,84.8,168,195,379]},
{name:'replace bb to ---- by init stringa|256',data:[309,282,362,461,1126]},
{name:'replace bb to ---- by init stringa|512',data:[700,674,824,1061,2808]},
{name:'replace bb to ---- by init stringa|1024',data:[1592,1535,1578,2174,5776]},
{name:'replace bb to ---- by init stringa|2048',data:[3230,3000,3172,4494,12197]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs29" > < h4 > < a id = "bs74494088982050398630" href = "#bs74494088982050398630" > #< / a > Replace All Str To Same Size< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1973" > replace bb to -- in std::string|64< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 115< / td > < td class = "benchmarkresult" > 180< / td > < td class = "benchmarkresult" > 193< / td > < td class = "benchmarkresult" > 557< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1973" > replace bb to -- in std::string|256< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 376< / td > < td class = "benchmarkresult" > 408< / td > < td class = "benchmarkresult" > 468< / td > < td class = "benchmarkresult" > 514< / td > < td class = "benchmarkresult" > 1747< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1973" > replace bb to -- in std::string|512< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 745< / td > < td class = "benchmarkresult" > 702< / td > < td class = "benchmarkresult" > 862< / td > < td class = "benchmarkresult" > 936< / td > < td class = "benchmarkresult" > 3241< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1973" > replace bb to -- in std::string|1024< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1481< / td > < td class = "benchmarkresult" > 1454< / td > < td class = "benchmarkresult" > 1609< / td > < td class = "benchmarkresult" > 1727< / td > < td class = "benchmarkresult" > 6280< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L1973" > replace bb to -- in std::string|2048< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2855< / td > < td class = "benchmarkresult" > 2708< / td > < td class = "benchmarkresult" > 3098< / td > < td class = "benchmarkresult" > 3417< / td > < td class = "benchmarkresult" > 12918< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2006" > replace bb to -- in lstringa< 8>|64< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 94.5< / td > < td class = "benchmarkresult" > 92.0< / td > < td class = "benchmarkresult" > 177< / td > < td class = "benchmarkresult" > 186< / td > < td class = "benchmarkresult" > 466< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2006" > replace bb to -- in lstringa< 8>|256< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 290< / td > < td class = "benchmarkresult" > 302< / td > < td class = "benchmarkresult" > 453< / td > < td class = "benchmarkresult" > 435< / td > < td class = "benchmarkresult" > 1429< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2006" > replace bb to -- in lstringa< 8>|512< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 554< / td > < td class = "benchmarkresult" > 541< / td > < td class = "benchmarkresult" > 797< / td > < td class = "benchmarkresult" > 783< / td > < td class = "benchmarkresult" > 2538< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2006" > replace bb to -- in lstringa< 8>|1024< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1047< / td > < td class = "benchmarkresult" > 1033< / td > < td class = "benchmarkresult" > 1460< / td > < td class = "benchmarkresult" > 1432< / td > < td class = "benchmarkresult" > 4898< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2006" > replace bb to -- in lstringa< 8>|2048< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2056< / td > < td class = "benchmarkresult" > 2000< / td > < td class = "benchmarkresult" > 2850< / td > < td class = "benchmarkresult" > 2808< / td > < td class = "benchmarkresult" > 9438< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2028" > replace bb to -- by init stringa|64< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 76.9< / td > < td class = "benchmarkresult" > 82.3< / td > < td class = "benchmarkresult" > 149< / td > < td class = "benchmarkresult" > 163< / td > < td class = "benchmarkresult" > 318< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2028" > replace bb to -- by init stringa|256< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 238< / td > < td class = "benchmarkresult" > 264< / td > < td class = "benchmarkresult" > 327< / td > < td class = "benchmarkresult" > 368< / td > < td class = "benchmarkresult" > 958< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2028" > replace bb to -- by init stringa|512< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 428< / td > < td class = "benchmarkresult" > 571< / td > < td class = "benchmarkresult" > 518< / td > < td class = "benchmarkresult" > 634< / td > < td class = "benchmarkresult" > 1814< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2028" > replace bb to -- by init stringa|1024< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 858< / td > < td class = "benchmarkresult" > 1012< / td > < td class = "benchmarkresult" > 979< / td > < td class = "benchmarkresult" > 1114< / td > < td class = "benchmarkresult" > 3500< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2028" > replace bb to -- by init stringa|2048< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-15 14:13:54 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1634< / td > < td class = "benchmarkresult" > 1962< / td > < td class = "benchmarkresult" > 1812< / td > < td class = "benchmarkresult" > 2145< / td > < td class = "benchmarkresult" > 6788< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' R e p l a c e A l l S t r T o S a m e S i z e ' ] = { i d : ' b s 2 9 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'replace bb to -- in std::string|64',data:[107,115,180,193,557]},
{name:'replace bb to -- in std::string|256',data:[376,408,468,514,1747]},
{name:'replace bb to -- in std::string|512',data:[745,702,862,936,3241]},
{name:'replace bb to -- in std::string|1024',data:[1481,1454,1609,1727,6280]},
{name:'replace bb to -- in std::string|2048',data:[2855,2708,3098,3417,12918]},
{name:'replace bb to -- in lstringa< 8 > |64',data:[94.5,92.0,177,186,466]},
{name:'replace bb to -- in lstringa< 8 > |256',data:[290,302,453,435,1429]},
{name:'replace bb to -- in lstringa< 8 > |512',data:[554,541,797,783,2538]},
{name:'replace bb to -- in lstringa< 8 > |1024',data:[1047,1033,1460,1432,4898]},
{name:'replace bb to -- in lstringa< 8 > |2048',data:[2056,2000,2850,2808,9438]},
{name:'replace bb to -- by init stringa|64',data:[76.9,82.3,149,163,318]},
{name:'replace bb to -- by init stringa|256',data:[238,264,327,368,958]},
{name:'replace bb to -- by init stringa|512',data:[428,571,518,634,1814]},
{name:'replace bb to -- by init stringa|1024',data:[858,1012,979,1114,3500]},
{name:'replace bb to -- by init stringa|2048',data:[1634,1962,1812,2145,6788]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs30" > < h4 > < a id = "bs8410196985047277720" href = "#bs8410196985047277720" > #< / a > Hash Map insert and find< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2125" > hashStrMapA< size_t> emplace & find stringa;< / a > < span class = "tooltiptext code" > void HashMapSimStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
hashStrMapA< size_t> store;
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
store.try_emplace(bs_sim[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_sim.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
auto find = store.find(bs_sim[idx]);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вставляем в hashStrMapA 10000 stringa длиной от 30 до 50
2026-01-21 11:59:17 +00:00
символов, а потом ищем их в ней
We insert 10,000 strings of length from 30 to 50 characters into
2026-02-15 14:13:54 +00:00
hashStrMapA, and then search for them in it.< / span > < / span > < / td > < td class = "benchmarkresult" > 3603351< / td > < td class = "benchmarkresult" > 3720383< / td > < td class = "benchmarkresult" > 3947744< / td > < td class = "benchmarkresult" > 4396542< / td > < td class = "benchmarkresult" > 5109286< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2149" > std::unordered_map< std::string, size_t> emplace & find std::string;< / a > < span class = "tooltiptext code" > void HashMapStdStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::unordered_map< std::string, size_t> store;
for (size_t idx = 0; idx < bs_std.size(); idx++) {
store.try_emplace(bs_std[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_std.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_std.size(); idx++) {
auto find = store.find(bs_std[idx]);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Т о же самое c std::string и std::unordered_map
2026-02-15 14:13:54 +00:00
Same thing with std::string and std::unordered_map< / span > < / span > < / td > < td class = "benchmarkresult" > 3597828< / td > < td class = "benchmarkresult" > 3743420< / td > < td class = "benchmarkresult" > 5668217< / td > < td class = "benchmarkresult" > 5663611< / td > < td class = "benchmarkresult" > 6102064< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2173" > hashStrMapA< size_t> emplace & find ssa;< / a > < span class = "tooltiptext code" > void HashMapSimSsa(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
hashStrMapA< size_t> store;
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
store.emplace(bs_sim[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_sim.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
ssa key = bs_sim[idx];
auto find = store.find(key);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Теперь вставляем stringa, а ищем ssa
2026-02-15 14:13:54 +00:00
Now we insert stringa and search for ssa< / span > < / span > < / td > < td class = "benchmarkresult" > 3647053< / td > < td class = "benchmarkresult" > 3829722< / td > < td class = "benchmarkresult" > 3479075< / td > < td class = "benchmarkresult" > 3927354< / td > < td class = "benchmarkresult" > 5120455< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2198" > std::unordered_map< std::string, size_t> emplace & find std::string_view;< / a > < span class = "tooltiptext code" > void HashMapStdStrView(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::unordered_map< std::string, size_t> store;
for (size_t idx = 0; idx < bs_std.size(); idx++) {
store.emplace(bs_std[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_std.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_std.size(); idx++) {
std::string_view key = bs_std[idx];
auto find = store.find(std::string{key});
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вставляем std::string, а ищем std::string_view
2026-02-15 14:13:54 +00:00
We insert std::string and look for std::string_view< / span > < / span > < / td > < td class = "benchmarkresult" > 4111005< / td > < td class = "benchmarkresult" > 3934639< / td > < td class = "benchmarkresult" > 6415411< / td > < td class = "benchmarkresult" > 6453271< / td > < td class = "benchmarkresult" > 7370000< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' H a s h M a p i n s e r t a n d f i n d ' ] = { i d : ' b s 3 0 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'hashStrMapA< size_t > emplace & find stringa;',data:[3603351,3720383,3947744,4396542,5109286]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string;',data:[3597828,3743420,5668217,5663611,6102064]},
{name:'hashStrMapA< size_t > emplace & find ssa;',data:[3647053,3829722,3479075,3927354,5120455]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string_view;',data:[4111005,3934639,6415411,6453271,7370000]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-14 10:09:54 +00:00
< div class = "benchset" id = "bs31" > < h4 > < a id = "bs131384792586914680410" href = "#bs131384792586914680410" > #< / a > Build Full Func Name< / h4 >
2026-02-08 11:17:03 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-15 14:13:54 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2408" > Build func full name std::string;< / a > < span class = "tooltiptext code" > std::string build_full_name_std() const {
2025-04-05 14:21:11 +00:00
std::string str{has_ret_type_resolver ? " any" sv : type_names_sv[(unsigned)ret_type]};
str += " " ;
str += std_name;
str += " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str += " , " ;
}
if (param.optional) {
str += " [" ;
}
param.allowed_types.to_stdstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str += " , " ;
}
str += " ..." ;
}
str += " )" ;
//std::cout < < " Len=" < < str.length() < < " , Cap=" < < str.capacity() < < " \n" ;
return str;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Обыденная задача, подобные часто могут встретится в работе:
По неким данным сгенерировать текст. В этом случае по данным
о неких функциях сформировать их полное имя с типами параметров и
2026-01-21 11:59:17 +00:00
возвращаемого значения. Алгоритм на 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
2026-02-15 14:13:54 +00:00
return values. The algorithm uses std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 674< / td > < td class = "benchmarkresult" > 871< / td > < td class = "benchmarkresult" > 1503< / td > < td class = "benchmarkresult" > 1582< / td > < td class = "benchmarkresult" > 5735< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2440" > Build func full name std::string 1;< / a > < span class = "tooltiptext code" > std::string build_full_name_std1() const {
2025-04-05 14:21:11 +00:00
std::string str{has_ret_type_resolver ? " any" sv : type_names_sv[(unsigned)ret_type]};
str += " " + std_name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str += " , " ;
}
if (param.optional) {
str += " [" ;
}
param.allowed_types.to_stdstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str += " , " ;
}
str += " ..." ;
}
str += " )" ;
//std::cout < < " Len=" < < str.length() < < " , Cap=" < < str.capacity() < < " \n" ;
return str;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Почти тот же алгоритм, но несколько последовательных
2026-01-21 11:59:17 +00:00
+= к строке заменены на одно += + + +.
Almost the same algorithm, but several consecutive
2026-02-15 14:13:54 +00:00
+= to a string are replaced with a single += + + +.< / span > < / span > < / td > < td class = "benchmarkresult" > 795< / td > < td class = "benchmarkresult" > 910< / td > < td class = "benchmarkresult" > 1585< / td > < td class = "benchmarkresult" > 1666< / td > < td class = "benchmarkresult" > 6226< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2470" > Build func full name std::stream;< / a > < span class = "tooltiptext code" > std::string build_full_name_stream() const {
2025-04-05 14:21:11 +00:00
std::ostringstream str;
if (has_ret_type_resolver) {
str < < " any" ;
} else {
str < < type_names_sv[(unsigned)ret_type];
}
str < < " " < < std_name < < " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str < < " , " ;
}
if (param.optional) {
str < < " [" ;
}
param.allowed_types.to_stream(str);
if (param.optional) {
str < < " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str < < " , " ;
}
str < < " ..." ;
}
str < < " )" ;
return str.str();
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Строим имя функции через std::ostringstream и < <
2026-02-15 14:13:54 +00:00
We construct the function name through std::ostringstream and < < < / span > < / span > < / td > < td class = "benchmarkresult" > 2574< / td > < td class = "benchmarkresult" > 2633< / td > < td class = "benchmarkresult" > 8326< / td > < td class = "benchmarkresult" > 9706< / td > < td class = "benchmarkresult" > 25795< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2381" > Build func full name stringa;< / a > < span class = "tooltiptext code" > stringa build_full_name() const {
2025-04-05 14:21:11 +00:00
lstringa< 512> str = e_choice(has_ret_type_resolver, " any" , type_names[(unsigned)ret_type]) + " " + name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
str += e_if(add_comma, " , " ) + e_if(param.optional, " [" );
param.allowed_types.to_simstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
return str + e_if(unlim_params, e_if(add_comma, " , " ) + " ..." ) + " )" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Реализация на simstr строках и строковых выражениях.
2026-01-21 11:59:17 +00:00
Инфа о параметрах добавляется в текущую строку
Implementation using simstr strings and string expressions.
2026-02-15 14:13:54 +00:00
Parameter information is appended to the current line.< / span > < / span > < / td > < td class = "benchmarkresult" > 485< / td > < td class = "benchmarkresult" > 451< / td > < td class = "benchmarkresult" > 760< / td > < td class = "benchmarkresult" > 871< / td > < td class = "benchmarkresult" > 2962< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2396" > Build func full name stringa 1;< / a > < span class = "tooltiptext code" > stringa build_full_name1() const {
2025-04-05 14:21:11 +00:00
lstringa< 512> str = e_choice(has_ret_type_resolver, " any" , type_names[(unsigned)ret_type]) + " " + name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
str += e_if(add_comma, " , " ) + e_if(param.optional, " [" ) + param.allowed_types.get_simstr() + e_if(param.optional, " ]" );
add_comma = true;
}
return str + e_if(unlim_params, e_if(add_comma, " , " ) + " ..." ) + " )" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Реализация на simstr строках и строковых выражениях.
Инфа о параметрах добавляется во временную строку, а потом
разом добавляется в текущую строку. Позволяет операции в цикле
2026-01-21 11:59:17 +00:00
записать в одну строку, но чуть проигрывает по времени выполнения.
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
2026-02-15 14:13:54 +00:00
to be written in a single string, but is slightly slower in execution time.< / span > < / span > < / td > < td class = "benchmarkresult" > 608< / td > < td class = "benchmarkresult" > 656< / td > < td class = "benchmarkresult" > 864< / td > < td class = "benchmarkresult" > 956< / td > < td class = "benchmarkresult" > 3450< / td > < / tr >
2026-02-14 10:09:54 +00:00
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' B u i l d F u l l F u n c N a m e ' ] = { i d : ' b s 3 1 ' , t e s t s : [
2026-02-15 14:13:54 +00:00
{name:'Build func full name std::string;',data:[674,871,1503,1582,5735]},
{name:'Build func full name std::string 1;',data:[795,910,1585,1666,6226]},
{name:'Build func full name std::stream;',data:[2574,2633,8326,9706,25795]},
{name:'Build func full name stringa;',data:[485,451,760,871,2962]},
{name:'Build func full name stringa 1;',data:[608,656,864,956,3450]}
]}< / script >
< div class = "benchset" id = "bs32" > < h4 > < a id = "bs36691618230457010710" href = "#bs36691618230457010710" > #< / a > Make Upper< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2610" > To upper case std::wstring< / a > < span class = "tooltiptext code" > void UpperCaseStd(benchmark::State& state) {
static const auto& loc = std::locale(" en_US.utf8" );
for (auto _: state) {
std::wstring test = L" TestПр иве тTest" ;
benchmark::DoNotOptimize(test);
std::transform(test.begin(), test.end(), test.begin(), [](wchar_t s) {
return std::toupper(s, loc);
});
benchmark::DoNotOptimize(test);
#ifdef CHECK_RESULT
if (test != L" TESTПР ИВ Е Т TEST" ) {
state.SkipWithError(" Bad upper case" );
}
#endif
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 151< / td > < td class = "benchmarkresult" > 165< / td > < td class = "benchmarkresult" > 1522< / td > < td class = "benchmarkresult" > 1452< / td > < td class = "benchmarkresult" > 1276< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.0/bench/bench_str.cpp#L2630" > To upper case lstringw< 15>< / a > < span class = "tooltiptext code" > void UpperCaseSim(benchmark::State& state) {
for (auto _: state) {
lstringw< 15> test = L" TestПр иве тTest" ;
benchmark::DoNotOptimize(test);
test.upper();
benchmark::DoNotOptimize(test);
#ifdef CHECK_RESULT
if (test != L" TESTПР ИВ Е Т TEST" ) {
state.SkipWithError(" Bad upper case" );
}
#endif
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 42.7< / td > < td class = "benchmarkresult" > 45.1< / td > < td class = "benchmarkresult" > 38.3< / td > < td class = "benchmarkresult" > 44.5< / td > < td class = "benchmarkresult" > 132< / td > < / tr >
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' M a k e U p p e r ' ] = { i d : ' b s 3 2 ' , t e s t s : [
{name:'To upper case std::wstring',data:[151,165,1522,1452,1276]},
{name:'To upper case lstringw< 15 > ',data:[42.7,45.1,38.3,44.5,132]}
2025-11-26 19:15:50 +00:00
]}< / script > < / body > < / html >