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 >
2026-02-27 20:05:49 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / span > < span class = "tooltip" > 32 X 2494.22 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)
2026-02-27 20:05:49 +00:00
Load Average: 0.03, 0.01, 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 >
2026-02-27 20:05:49 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / span > < span class = "tooltip" > 32 X 2494.22 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)
2026-02-27 20:05:49 +00:00
Load Average: 0.03, 0.45, 0.43
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 >
2026-02-27 20:05:49 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / span > < span class = "tooltip" > 32 X 2494.22 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)
2026-02-27 20:05:49 +00:00
L3 Unified 40960 KiB (x1)
Load Average: 0.00, 0.00, 0.00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl2" checked onchange = "buildCharts()" / > < / li >
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, Clang-22< / 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-27 20:05:49 +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:
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 = "pl4" checked onchange = "buildCharts()" / > < / li >
< li > < span class = "platform" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / 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 = "pl5" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< / ul > < / div > < / div >
2026-02-27 20:05:49 +00:00
< script > const platform _names = [ 'Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22' , 'Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++' , 'Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15' , 'Xeon E5-2682 v4, Windows 10, Clang-22' , 'Xeon E5-2682 v4, Windows 10, MSVC-19' , 'Xeon E5-2682 v4, WASM Chrome 143, Clang-22' ] ; < / 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 >
2026-02-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 165< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 160< / td > < td class = "benchmarkresult" > 207< / td > < td class = "benchmarkresult" > 252< / td > < td class = "benchmarkresult" > 994< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 325< / td > < td class = "benchmarkresult" > 268< / td > < td class = "benchmarkresult" > 318< / td > < td class = "benchmarkresult" > 808< / td > < td class = "benchmarkresult" > 909< / td > < td class = "benchmarkresult" > 2551< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 136< / td > < td class = "benchmarkresult" > 141< / td > < td class = "benchmarkresult" > 108< / td > < td class = "benchmarkresult" > 260< / td > < td class = "benchmarkresult" > 272< / td > < td class = "benchmarkresult" > 591< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
but it's not as convenient or advanced as simstr.< / span > < / span > < / td > < td class = "benchmarkresult" > 54.8< / td > < td class = "benchmarkresult" > 58.3< / td > < td class = "benchmarkresult" > 42.7< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 127< / 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.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 73.7< / td > < td class = "benchmarkresult" > 94.9< / td > < td class = "benchmarkresult" > 77.9< / td > < td class = "benchmarkresult" > 182< / td > < td class = "benchmarkresult" > 196< / td > < td class = "benchmarkresult" > 643< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 44.8< / td > < td class = "benchmarkresult" > 45.2< / td > < td class = "benchmarkresult" > 33.6< / td > < td class = "benchmarkresult" > 106< / td > < td class = "benchmarkresult" > 111< / td > < td class = "benchmarkresult" > 164< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 40.5< / td > < td class = "benchmarkresult" > 39.3< / td > < td class = "benchmarkresult" > 39.7< / td > < td class = "benchmarkresult" > 92.9< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 131< / 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-27 20:05:49 +00:00
{name:'Concat email std::format',data:[165,167,160,207,252,994]},
{name:'Concat email std::stringstream',data:[325,268,318,808,909,2551]},
{name:'Concat email stringzilla append',data:[136,141,108,260,272,591]},
{name:'Concat email stringzilla concat',data:[54.8,58.3,42.7,125,127,222]},
{name:'Concat email std::string append',data:[73.7,94.9,77.9,182,196,643]},
{name:'Concat email std::string by strexpr',data:[44.8,45.2,33.6,106,111,164]},
{name:'Concat email stringa',data:[40.5,39.3,39.7,92.9,101,131]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 216< / td > < td class = "benchmarkresult" > 239< / td > < td class = "benchmarkresult" > 207< / td > < td class = "benchmarkresult" > 265< / td > < td class = "benchmarkresult" > 331< / td > < td class = "benchmarkresult" > 1982< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 100< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 156< / td > < td class = "benchmarkresult" > 211< / td > < td class = "benchmarkresult" > 980< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
while in stringa , the entire test is included in SSO.< / span > < / span > < / td > < td class = "benchmarkresult" > 65.6< / td > < td class = "benchmarkresult" > 65.1< / td > < td class = "benchmarkresult" > 68.1< / td > < td class = "benchmarkresult" > 66.5< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 352< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 71.2< / td > < td class = "benchmarkresult" > 67.8< / td > < td class = "benchmarkresult" > 76.4< / td > < td class = "benchmarkresult" > 74.2< / td > < td class = "benchmarkresult" > 113< / td > < td class = "benchmarkresult" > 377< / 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-27 20:05:49 +00:00
{name:'Concat std::string and number by std to std::string',data:[216,239,207,265,331,1982]},
{name:'Concat std::string and number by StrExpr to std::string',data:[104,100,101,156,211,980]},
{name:'Concat stringa and number by StrExpr to simstr::stringa',data:[65.6,65.1,68.1,66.5,102,352]},
{name:'Concat stringa and number by e_concat to simstr::stringa',data:[71.2,67.8,76.4,74.2,113,377]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 703< / td > < td class = "benchmarkresult" > 703< / td > < td class = "benchmarkresult" > 742< / td > < td class = "benchmarkresult" > 701< / td > < td class = "benchmarkresult" > 1043< / td > < td class = "benchmarkresult" > 3864< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 835< / td > < td class = "benchmarkresult" > 804< / td > < td class = "benchmarkresult" > 850< / td > < td class = "benchmarkresult" > 1465< / td > < td class = "benchmarkresult" > 1834< / td > < td class = "benchmarkresult" > 5212< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 207< / td > < td class = "benchmarkresult" > 218< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 182< / td > < td class = "benchmarkresult" > 254< / td > < td class = "benchmarkresult" > 1159< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 133< / td > < td class = "benchmarkresult" > 145< / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 119< / td > < td class = "benchmarkresult" > 912< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 117< / td > < td class = "benchmarkresult" > 115< / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 67.1< / td > < td class = "benchmarkresult" > 101< / 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.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 75.9< / td > < td class = "benchmarkresult" > 105< / 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.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 182< / td > < td class = "benchmarkresult" > 183< / td > < td class = "benchmarkresult" > 165< / td > < td class = "benchmarkresult" > 145< / td > < td class = "benchmarkresult" > 171< / td > < td class = "benchmarkresult" > 350< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 314< / td > < td class = "benchmarkresult" > 320< / td > < td class = "benchmarkresult" > 275< / td > < td class = "benchmarkresult" > 292< / td > < td class = "benchmarkresult" > 359< / td > < td class = "benchmarkresult" > 928< / 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-27 20:05:49 +00:00
{name:'Concat std::string and format hex number and literal to std::string',data:[703,703,742,701,1043,3864]},
{name:'std::format std::string and hex number by literal to std::string',data:[835,804,850,1465,1834,5212]},
{name:'Concat std::string and std::to_chars and string to std::string',data:[207,218,194,182,254,1159]},
{name:'Concat std::string and hex number and literal by StrExpr to std::string',data:[133,145,121,83.5,119,912]},
{name:'Concat stringa and hex number and literal by StrExpr to simstr::stringa',data:[117,115,116,67.1,101,221]},
{name:'Concat stringa and hex number and literal by e_concat to simstr::stringa',data:[124,123,121,75.9,105,221]},
{name:'Subst stringa and hex number by e_subst literal to simstr::stringa',data:[182,183,165,145,171,350]},
{name:'Subst stringa and hex number by e_vsubst stra to simstr::stringa',data:[314,320,275,292,359,928]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 265< / td > < td class = "benchmarkresult" > 278< / td > < td class = "benchmarkresult" > 259< / td > < td class = "benchmarkresult" > 668< / td > < td class = "benchmarkresult" > 695< / td > < td class = "benchmarkresult" > 418< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 350< / td > < td class = "benchmarkresult" > 357< / td > < td class = "benchmarkresult" > 314< / td > < td class = "benchmarkresult" > 753< / td > < td class = "benchmarkresult" > 828< / td > < td class = "benchmarkresult" > 657< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 628< / td > < td class = "benchmarkresult" > 640< / td > < td class = "benchmarkresult" > 571< / td > < td class = "benchmarkresult" > 1052< / td > < td class = "benchmarkresult" > 1166< / td > < td class = "benchmarkresult" > 1440< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 703< / td > < td class = "benchmarkresult" > 668< / td > < td class = "benchmarkresult" > 632< / td > < td class = "benchmarkresult" > 1408< / td > < td class = "benchmarkresult" > 1577< / td > < td class = "benchmarkresult" > 2237< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 873< / td > < td class = "benchmarkresult" > 795< / td > < td class = "benchmarkresult" > 747< / td > < td class = "benchmarkresult" > 1384< / td > < td class = "benchmarkresult" > 1440< / td > < td class = "benchmarkresult" > 2986< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 982< / td > < td class = "benchmarkresult" > 1216< / td > < td class = "benchmarkresult" > 1210< / td > < td class = "benchmarkresult" > 1574< / td > < td class = "benchmarkresult" > 1921< / td > < td class = "benchmarkresult" > 3132< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 975< / td > < td class = "benchmarkresult" > 1243< / td > < td class = "benchmarkresult" > 1241< / td > < td class = "benchmarkresult" > 1578< / td > < td class = "benchmarkresult" > 1914< / td > < td class = "benchmarkresult" > 3119< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L421" > std::format with std::formatted_size< / a > < span class = "tooltiptext code" > void StdFormatSize(benchmark::State& state) {
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
size_t len = std::formatted_size(" abcdefghihklmopqr {:#010o} end" , i);
std::string str(len, 0);
std::format_to_n(str.data(), len, " abcdefghihklmopqr {:#010o} end" , i);
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1818< / td > < td class = "benchmarkresult" > 2159< / td > < td class = "benchmarkresult" > 2117< / td > < td class = "benchmarkresult" > 2443< / td > < td class = "benchmarkresult" > 2861< / td > < td class = "benchmarkresult" > 5329< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2373< / td > < td class = "benchmarkresult" > 2594< / td > < td class = "benchmarkresult" > 1954< / td > < td class = "benchmarkresult" > 6589< / td > < td class = "benchmarkresult" > 6947< / td > < td class = "benchmarkresult" > 8569< / 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-27 20:05:49 +00:00
{name:'"abcdefghihklmopqr "_ss + i / 0x8a010_fmt + " end"',data:[265,278,259,668,695,418]},
{name:'e_subst("abcdefghihklmopqr {} end", i / 0x8a010_fmt)',data:[350,357,314,753,828,657]},
{name:'e_vsubst(pattern, i / 0x8a010_fmt)',data:[628,640,571,1052,1166,1440]},
{name:'fmt::format(FMT_COMPILE("abcdefghihklmopqr {:#010o} end"), i)',data:[703,668,632,1408,1577,2237]},
{name:'fmt::format("abcdefghihklmopqr {:#010o} end", i)',data:[873,795,747,1384,1440,2986]},
{name:'std::format("abcdefghihklmopqr {:#010o} end", i)',data:[982,1216,1210,1574,1921,3132]},
{name:'std::vformat(pattern, std::make_format_args(i))',data:[975,1243,1241,1578,1914,3119]},
{name:'std::format with std::formatted_size',data:[1818,2159,2117,2443,2861,5329]},
{name:'strm < < "abcdefghihklmopqr 0" < < std::oct < < std::setw ( 9 ) < < std::setfill ( \ ' 0 \ ' ) < < i < < " end " ' , data: [ 2373 , 2594 , 1954 , 6589 , 6947 , 8569 ] }
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L443" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 47.2< / td > < td class = "benchmarkresult" > 34.0< / td > < td class = "benchmarkresult" > 45.3< / td > < td class = "benchmarkresult" > 40.4< / td > < td class = "benchmarkresult" > 55.1< / 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.2/bench/bench_str.cpp#L454" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 33.0< / td > < td class = "benchmarkresult" > 36.0< / td > < td class = "benchmarkresult" > 29.9< / td > < td class = "benchmarkresult" > 38.7< / td > < td class = "benchmarkresult" > 80.2< / td > < td class = "benchmarkresult" > 131< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L465" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 29.2< / td > < td class = "benchmarkresult" > 29.4< / td > < td class = "benchmarkresult" > 26.7< / td > < td class = "benchmarkresult" > 29.3< / td > < td class = "benchmarkresult" > 52.4< / td > < td class = "benchmarkresult" > 101< / 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-27 20:05:49 +00:00
{name:'Concat std::string by std to std::string',data:[47.2,34.0,45.3,40.4,55.1,116]},
{name:'Concat std::string by StrExpr to std::string',data:[33.0,36.0,29.9,38.7,80.2,131]},
{name:'Concat stringa by StrExpr to stringa',data:[29.2,29.4,26.7,29.3,52.4,101]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L481" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 110< / td > < td class = "benchmarkresult" > 90.6< / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 205< / td > < td class = "benchmarkresult" > 223< / td > < td class = "benchmarkresult" > 214< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L486" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 52.6< / td > < td class = "benchmarkresult" > 43.1< / td > < td class = "benchmarkresult" > 38.4< / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 107< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L490" > 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-27 20:05:49 +00:00
it is collected in a stack-based buffer, without allocation or deallocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 18.8< / td > < td class = "benchmarkresult" > 16.6< / td > < td class = "benchmarkresult" > 14.4< / td > < td class = "benchmarkresult" > 20.8< / td > < td class = "benchmarkresult" > 28.2< / td > < td class = "benchmarkresult" > 57.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L494" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 135< / td > < td class = "benchmarkresult" > 118< / td > < td class = "benchmarkresult" > 211< / td > < td class = "benchmarkresult" > 221< / td > < td class = "benchmarkresult" > 271< / 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-27 20:05:49 +00:00
{name:'Find concat three std::string',data:[110,90.6,116,205,223,214]},
{name:'Find concat three strexpr',data:[52.6,43.1,38.4,114,124,107]},
{name:'Find concat three simstr',data:[18.8,16.6,14.4,20.8,28.2,57.6]},
{name:'Find concat three stringzilla string',data:[157,135,118,211,221,271]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L570" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.23< / td > < td class = "benchmarkresult" > 6.79< / td > < td class = "benchmarkresult" > 8.40< / td > < td class = "benchmarkresult" > 8.21< / td > < td class = "benchmarkresult" > 17.5< / td > < td class = "benchmarkresult" > 23.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L582" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.61< / td > < td class = "benchmarkresult" > 5.99< / td > < td class = "benchmarkresult" > 6.68< / td > < td class = "benchmarkresult" > 7.48< / td > < td class = "benchmarkresult" > 14.1< / td > < td class = "benchmarkresult" > 25.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L589" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.20< / td > < td class = "benchmarkresult" > 4.28< / td > < td class = "benchmarkresult" > 4.83< / td > < td class = "benchmarkresult" > 7.46< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 21.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L570" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 59.7< / td > < td class = "benchmarkresult" > 88.9< / td > < td class = "benchmarkresult" > 72.5< / td > < td class = "benchmarkresult" > 69.3< / td > < td class = "benchmarkresult" > 83.6< / td > < td class = "benchmarkresult" > 400< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L582" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 30.9< / td > < td class = "benchmarkresult" > 38.8< / td > < td class = "benchmarkresult" > 26.5< / td > < td class = "benchmarkresult" > 32.2< / td > < td class = "benchmarkresult" > 38.1< / 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.2/bench/bench_str.cpp#L589" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 23.5< / td > < td class = "benchmarkresult" > 21.7< / td > < td class = "benchmarkresult" > 25.9< / td > < td class = "benchmarkresult" > 38.4< / td > < td class = "benchmarkresult" > 73.2< / 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-27 20:05:49 +00:00
{name:'BuildTypeNameStr 0/0',data:[7.23,6.79,8.40,8.21,17.5,23.2]},
{name:'BuildTypeNameExp 0/0',data:[6.61,5.99,6.68,7.48,14.1,25.8]},
{name:'BuildTypeNameSim 0/0',data:[4.20,4.28,4.83,7.46,16.3,21.4]},
{name:'BuildTypeNameStr 10/10',data:[59.7,88.9,72.5,69.3,83.6,400]},
{name:'BuildTypeNameExp 10/10',data:[30.9,38.8,26.5,32.2,38.1,126]},
{name:'BuildTypeNameSim 10/10',data:[23.9,23.5,21.7,25.9,38.4,73.2]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L643" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 208< / td > < td class = "benchmarkresult" > 233< / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 310< / td > < td class = "benchmarkresult" > 360< / td > < td class = "benchmarkresult" > 546< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L661" > 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-27 20:05:49 +00:00
simstr has a string expression for replacing substrings out of the box.< / span > < / span > < / td > < td class = "benchmarkresult" > 158< / td > < td class = "benchmarkresult" > 140< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 213< / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 247< / 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-27 20:05:49 +00:00
{name:'Concat with replace str',data:[208,233,219,310,360,546]},
{name:'Concat with replace exp',data:[158,140,129,213,219,247]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
Empty lines, nothing unusual.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 0.742< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 2.52< / td > < td class = "benchmarkresult" > 2.35< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.389< / td > < td class = "benchmarkresult" > 0.373< / td > < td class = "benchmarkresult" > 0.740< / td > < td class = "benchmarkresult" > 0.363< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 0.772< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.370< / td > < td class = "benchmarkresult" > 0.375< / td > < td class = "benchmarkresult" > 0.181< / td > < td class = "benchmarkresult" > 0.357< / td > < td class = "benchmarkresult" > 1.81< / td > < td class = "benchmarkresult" > 0.359< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.770< / td > < td class = "benchmarkresult" > 0.763< / td > < td class = "benchmarkresult" > 0.737< / td > < td class = "benchmarkresult" > 0.741< / td > < td class = "benchmarkresult" > 2.22< / td > < td class = "benchmarkresult" > 2.12< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.08< / td > < td class = "benchmarkresult" > 2.54< / td > < td class = "benchmarkresult" > 2.26< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L695" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 2.56< / td > < td class = "benchmarkresult" > 2.41< / 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-27 20:05:49 +00:00
{name:'std::string e;',data:[1.14,0.742,1.09,1.09,2.52,2.35]},
{name:'std::string_view e;',data:[0.389,0.373,0.740,0.363,1.82,0.772]},
{name:'ssa e;',data:[0.370,0.375,0.181,0.357,1.81,0.359]},
{name:'stringa e;',data:[0.770,0.763,0.737,0.741,2.22,2.12]},
{name:'lstringa< 20 > e;',data:[1.11,1.10,1.10,1.08,2.54,2.26]},
{name:'lstringa< 40 > e;',data:[1.11,1.10,1.10,1.09,2.56,2.41]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
time is spent only copying 10 bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.95< / td > < td class = "benchmarkresult" > 1.46< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 2.58< / td > < td class = "benchmarkresult" > 2.49< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
a pointer to text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.741< / td > < td class = "benchmarkresult" > 0.741< / td > < td class = "benchmarkresult" > 0.730< / td > < td class = "benchmarkresult" > 0.718< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.08< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.374< / td > < td class = "benchmarkresult" > 0.370< / td > < td class = "benchmarkresult" > 0.729< / td > < td class = "benchmarkresult" > 0.367< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 0.779< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
only a pointer to the text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 2.55< / 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.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
time is spent only on copying bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.93< / td > < td class = "benchmarkresult" > 1.86< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 2.53< / td > < td class = "benchmarkresult" > 2.58< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L710" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.89< / td > < td class = "benchmarkresult" > 1.87< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 2.55< / td > < td class = "benchmarkresult" > 2.55< / 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-27 20:05:49 +00:00
{name:'std::string e = "Test text";',data:[1.95,1.46,1.83,1.83,2.58,2.49]},
{name:'std::string_view e = "Test text";',data:[0.741,0.741,0.730,0.718,1.83,1.08]},
{name:'ssa e = "Test text";',data:[0.374,0.370,0.729,0.367,1.82,0.779]},
{name:'stringa e = "Test text";',data:[1.13,1.12,1.10,1.10,2.55,2.17]},
{name:'lstringa< 20 > e = "Test text";',data:[1.93,1.86,1.83,1.82,2.53,2.58]},
{name:'lstringa< 40 > e = "Test text";',data:[1.89,1.87,1.85,1.82,2.55,2.55]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...< / span > < / span > < / td > < td class = "benchmarkresult" > 20.2< / td > < td class = "benchmarkresult" > 18.8< / td > < td class = "benchmarkresult" > 19.1< / td > < td class = "benchmarkresult" > 76.0< / td > < td class = "benchmarkresult" > 78.9< / td > < td class = "benchmarkresult" > 23.4< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
remember the pointer to the text and its size.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.732< / td > < td class = "benchmarkresult" > 0.740< / td > < td class = "benchmarkresult" > 0.734< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 1.15< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.369< / td > < td class = "benchmarkresult" > 0.371< / td > < td class = "benchmarkresult" > 0.746< / td > < td class = "benchmarkresult" > 0.362< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 0.757< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
stringa doesn't lag behind on constant literals!< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 2.87< / 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.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
Obviously, 30 characters already require allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 20.5< / td > < td class = "benchmarkresult" > 19.2< / td > < td class = "benchmarkresult" > 20.1< / td > < td class = "benchmarkresult" > 76.7< / td > < td class = "benchmarkresult" > 76.9< / td > < td class = "benchmarkresult" > 29.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L725" > 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-27 20:05:49 +00:00
bytes are simply copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 2.50< / td > < td class = "benchmarkresult" > 3.27< / td > < td class = "benchmarkresult" > 2.95< / 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-27 20:05:49 +00:00
{name:'std::string e = "123456789012345678901234567890";',data:[20.2,18.8,19.1,76.0,78.9,23.4]},
{name:'std::string_view e = "123456789012345678901234567890";',data:[0.738,0.732,0.740,0.734,1.84,1.15]},
{name:'ssa e = "123456789012345678901234567890";',data:[0.369,0.371,0.746,0.362,1.85,0.757]},
{name:'stringa e = "123456789012345678901234567890";',data:[1.10,1.11,1.11,1.09,2.87,2.17]},
{name:'lstringa< 20 > e = "123456789012345678901234567890";',data:[20.5,19.2,20.1,76.7,76.9,29.8]},
{name:'lstringa< 40 > e = "123456789012345678901234567890";',data:[2.57,1.84,1.82,2.50,3.27,2.95]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
The string is within the SSO, so it just copies the bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 5.69< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 4.80< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 5.99< / td > < td class = "benchmarkresult" > 4.03< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.372< / td > < td class = "benchmarkresult" > 0.373< / td > < td class = "benchmarkresult" > 0.366< / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 3.47< / td > < td class = "benchmarkresult" > 1.15< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
string information is copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.377< / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 0.375< / td > < td class = "benchmarkresult" > 0.367< / td > < td class = "benchmarkresult" > 3.46< / td > < td class = "benchmarkresult" > 1.09< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
especially if it is initialized with a literal.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.08< / td > < td class = "benchmarkresult" > 4.00< / td > < td class = "benchmarkresult" > 2.49< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
In both cases, the internal buffer is sufficient.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.44< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 4.77< / td > < td class = "benchmarkresult" > 4.74< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L740" > 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-27 20:05:49 +00:00
Only bytes are copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 1.45< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 4.89< / td > < td class = "benchmarkresult" > 5.17< / 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-27 20:05:49 +00:00
{name:'std::string e = "Test text"; auto c{e};',data:[5.69,1.12,4.80,1.84,5.99,4.03]},
{name:'std::string_view e = "Test text"; auto c{e};',data:[0.372,0.373,0.366,0.368,3.47,1.15]},
{name:'ssa e = "Test text"; auto c{e};',data:[0.377,0.368,0.375,0.367,3.46,1.09]},
{name:'stringa e = "Test text"; auto c{e};',data:[1.12,1.10,1.10,1.08,4.00,2.49]},
{name:'lstringa< 20 > e = "Test text"; auto c{e};',data:[1.12,1.11,1.44,1.10,4.77,4.74]},
{name:'lstringa< 40 > e = "Test text"; auto c{e};',data:[1.14,1.82,1.45,1.10,4.89,5.17]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
SSO is no longer sufficient. And again, how allocation lags under Windows...< / span > < / span > < / td > < td class = "benchmarkresult" > 19.8< / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 22.5< / td > < td class = "benchmarkresult" > 74.9< / td > < td class = "benchmarkresult" > 74.9< / td > < td class = "benchmarkresult" > 49.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.737< / td > < td class = "benchmarkresult" > 0.730< / td > < td class = "benchmarkresult" > 0.731< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.07< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.373< / td > < td class = "benchmarkresult" > 0.372< / td > < td class = "benchmarkresult" > 0.733< / td > < td class = "benchmarkresult" > 0.365< / td > < td class = "benchmarkresult" > 1.81< / td > < td class = "benchmarkresult" > 0.784< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
compare with the previous benchmark.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 6.70< / td > < td class = "benchmarkresult" > 1.08< / td > < td class = "benchmarkresult" > 2.90< / td > < td class = "benchmarkresult" > 2.28< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
Doesn't fit, allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 20.4< / td > < td class = "benchmarkresult" > 18.2< / td > < td class = "benchmarkresult" > 19.5< / td > < td class = "benchmarkresult" > 75.1< / td > < td class = "benchmarkresult" > 81.1< / td > < td class = "benchmarkresult" > 23.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L757" > 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-27 20:05:49 +00:00
Placed in the internal buffer.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.74< / td > < td class = "benchmarkresult" > 5.02< / td > < td class = "benchmarkresult" > 4.07< / td > < td class = "benchmarkresult" > 4.88< / td > < td class = "benchmarkresult" > 7.73< / td > < td class = "benchmarkresult" > 16.7< / 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-27 20:05:49 +00:00
{name:'std::string e = "123456789012345678901234567890"; auto c{e};',data:[19.8,24.0,22.5,74.9,74.9,49.0]},
{name:'std::string_view e = "123456789012345678901234567890"; auto c{e};',data:[0.738,0.737,0.730,0.731,1.83,1.07]},
{name:'ssa e = "123456789012345678901234567890"; auto c{e};',data:[0.373,0.372,0.733,0.365,1.81,0.784]},
{name:'stringa e = "123456789012345678901234567890"; auto c{e};',data:[1.12,1.12,6.70,1.08,2.90,2.28]},
{name:'lstringa< 20 > e = "123456789012345678901234567890"; auto c{e};',data:[20.4,18.2,19.5,75.1,81.1,23.8]},
{name:'lstringa< 40 > e = "123456789012345678901234567890"; auto c{e};',data:[4.74,5.02,4.07,4.88,7.73,16.7]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
stringzilla is more focused on searching large strings within large strings.< / span > < / span > < / td > < td class = "benchmarkresult" > 98.1< / td > < td class = "benchmarkresult" > 96.2< / td > < td class = "benchmarkresult" > 84.9< / td > < td class = "benchmarkresult" > 95.3< / td > < td class = "benchmarkresult" > 115< / 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.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
However, Windows and Linux are clearly in different weight classes.< / span > < / span > < / td > < td class = "benchmarkresult" > 7.04< / td > < td class = "benchmarkresult" > 7.46< / td > < td class = "benchmarkresult" > 6.64< / td > < td class = "benchmarkresult" > 39.1< / td > < td class = "benchmarkresult" > 40.5< / td > < td class = "benchmarkresult" > 43.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.15< / td > < td class = "benchmarkresult" > 7.13< / td > < td class = "benchmarkresult" > 7.05< / td > < td class = "benchmarkresult" > 37.9< / td > < td class = "benchmarkresult" > 39.5< / td > < td class = "benchmarkresult" > 41.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.45< / td > < td class = "benchmarkresult" > 6.97< / td > < td class = "benchmarkresult" > 6.73< / td > < td class = "benchmarkresult" > 18.1< / td > < td class = "benchmarkresult" > 22.0< / td > < td class = "benchmarkresult" > 41.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 8.20< / td > < td class = "benchmarkresult" > 7.88< / td > < td class = "benchmarkresult" > 7.01< / td > < td class = "benchmarkresult" > 19.2< / td > < td class = "benchmarkresult" > 29.9< / td > < td class = "benchmarkresult" > 40.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.82< / td > < td class = "benchmarkresult" > 6.73< / td > < td class = "benchmarkresult" > 6.53< / td > < td class = "benchmarkresult" > 17.2< / td > < td class = "benchmarkresult" > 21.9< / td > < td class = "benchmarkresult" > 39.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L774" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.70< / td > < td class = "benchmarkresult" > 6.79< / td > < td class = "benchmarkresult" > 6.27< / td > < td class = "benchmarkresult" > 17.6< / td > < td class = "benchmarkresult" > 22.9< / td > < td class = "benchmarkresult" > 39.2< / 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-27 20:05:49 +00:00
{name:'sz::string::find;',data:[98.1,96.2,84.9,95.3,115,123]},
{name:'std::string::find;',data:[7.04,7.46,6.64,39.1,40.5,43.8]},
{name:'std::string_view::find;',data:[7.15,7.13,7.05,37.9,39.5,41.6]},
{name:'ssa::find;',data:[7.45,6.97,6.73,18.1,22.0,41.1]},
{name:'stringa::find;',data:[8.20,7.88,7.01,19.2,29.9,40.6]},
{name:'lstringa< 20 > ::find;',data:[6.82,6.73,6.53,17.2,21.9,39.8]},
{name:'lstringa< 40 > ::find;',data:[6.70,6.79,6.27,17.6,22.9,39.2]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.24< / td > < td class = "benchmarkresult" > 1.17< / td > < td class = "benchmarkresult" > 4.85< / td > < td class = "benchmarkresult" > 1.90< / td > < td class = "benchmarkresult" > 5.09< / td > < td class = "benchmarkresult" > 45.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
smaller, as far as I remember: 11 characters + 0.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 1.22< / td > < td class = "benchmarkresult" > 27.2< / td > < td class = "benchmarkresult" > 79.1< / td > < td class = "benchmarkresult" > 82.6< / td > < td class = "benchmarkresult" > 51.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
Then the time for copying bytes is simply added.< / span > < / span > < / td > < td class = "benchmarkresult" > 27.4< / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 27.7< / td > < td class = "benchmarkresult" > 77.6< / td > < td class = "benchmarkresult" > 83.1< / td > < td class = "benchmarkresult" > 48.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.6< / td > < td class = "benchmarkresult" > 24.6< / td > < td class = "benchmarkresult" > 21.2< / td > < td class = "benchmarkresult" > 78.3< / td > < td class = "benchmarkresult" > 83.0< / td > < td class = "benchmarkresult" > 49.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.1< / td > < td class = "benchmarkresult" > 23.8< / td > < td class = "benchmarkresult" > 22.3< / td > < td class = "benchmarkresult" > 81.9< / td > < td class = "benchmarkresult" > 85.5< / td > < td class = "benchmarkresult" > 53.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.2< / td > < td class = "benchmarkresult" > 25.7< / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 80.8< / td > < td class = "benchmarkresult" > 90.0< / td > < td class = "benchmarkresult" > 52.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.7< / td > < td class = "benchmarkresult" > 26.5< / td > < td class = "benchmarkresult" > 28.4< / td > < td class = "benchmarkresult" > 84.0< / td > < td class = "benchmarkresult" > 89.5< / td > < td class = "benchmarkresult" > 59.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.8< / td > < td class = "benchmarkresult" > 27.7< / td > < td class = "benchmarkresult" > 25.2< / td > < td class = "benchmarkresult" > 86.9< / td > < td class = "benchmarkresult" > 91.4< / td > < td class = "benchmarkresult" > 77.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 29.1< / td > < td class = "benchmarkresult" > 31.2< / td > < td class = "benchmarkresult" > 27.8< / td > < td class = "benchmarkresult" > 89.8< / td > < td class = "benchmarkresult" > 93.4< / td > < td class = "benchmarkresult" > 86.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 47.8< / td > < td class = "benchmarkresult" > 38.2< / td > < td class = "benchmarkresult" > 35.5< / td > < td class = "benchmarkresult" > 97.2< / td > < td class = "benchmarkresult" > 98.8< / td > < td class = "benchmarkresult" > 106< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 86.4< / td > < td class = "benchmarkresult" > 118< / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 132< / 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.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
The longer the string, the longer it takes to create a copy.< / span > < / span > < / td > < td class = "benchmarkresult" > 146< / td > < td class = "benchmarkresult" > 115< / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 180< / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 165< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
meaning it must store characters itself.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.07< / td > < td class = "benchmarkresult" > 4.03< / td > < td class = "benchmarkresult" > 2.50< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
increment was replaced with a regular one, judging by the time.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.08< / td > < td class = "benchmarkresult" > 4.07< / td > < td class = "benchmarkresult" > 4.92< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
copies faster than 15 in std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.08< / td > < td class = "benchmarkresult" > 3.99< / td > < td class = "benchmarkresult" > 4.77< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
Time is added for the atomic counter increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.73< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.77< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.76< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.74< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.7< / td > < td class = "benchmarkresult" > 4.74< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 4.75< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 4.75< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 5.34< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +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.0< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 5.09< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
WASM has a 32-bit architecture, so SSO is up to 19 characters.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.47< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 4.55< / td > < td class = "benchmarkresult" > 4.26< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.42< / td > < td class = "benchmarkresult" > 5.27< / td > < td class = "benchmarkresult" > 4.43< / td > < td class = "benchmarkresult" > 4.79< / td > < td class = "benchmarkresult" > 9.64< / td > < td class = "benchmarkresult" > 16.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.17< / td > < td class = "benchmarkresult" > 5.22< / td > < td class = "benchmarkresult" > 4.43< / td > < td class = "benchmarkresult" > 4.81< / td > < td class = "benchmarkresult" > 9.66< / td > < td class = "benchmarkresult" > 36.5< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
And then it starts to behave like std::string when copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 23.1< / td > < td class = "benchmarkresult" > 23.3< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 82.0< / td > < td class = "benchmarkresult" > 37.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.1< / td > < td class = "benchmarkresult" > 22.8< / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 80.7< / td > < td class = "benchmarkresult" > 83.4< / td > < td class = "benchmarkresult" > 39.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.9< / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 25.3< / td > < td class = "benchmarkresult" > 77.3< / td > < td class = "benchmarkresult" > 84.9< / td > < td class = "benchmarkresult" > 39.5< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.9< / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 40.0< / td > < td class = "benchmarkresult" > 83.4< / td > < td class = "benchmarkresult" > 88.6< / td > < td class = "benchmarkresult" > 39.7< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27.3< / td > < td class = "benchmarkresult" > 26.8< / td > < td class = "benchmarkresult" > 27.0< / td > < td class = "benchmarkresult" > 86.6< / td > < td class = "benchmarkresult" > 88.4< / td > < td class = "benchmarkresult" > 63.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 29.8< / td > < td class = "benchmarkresult" > 29.0< / td > < td class = "benchmarkresult" > 29.1< / td > < td class = "benchmarkresult" > 88.1< / td > < td class = "benchmarkresult" > 91.7< / td > < td class = "benchmarkresult" > 71.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 95.4< / td > < td class = "benchmarkresult" > 78.3< / td > < td class = "benchmarkresult" > 97.4< / td > < td class = "benchmarkresult" > 94.7< / td > < td class = "benchmarkresult" > 95.5< / td > < td class = "benchmarkresult" > 84.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 105< / td > < td class = "benchmarkresult" > 74.6< / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 104< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 122< / td > < td class = "benchmarkresult" > 89.5< / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 191< / td > < td class = "benchmarkresult" > 186< / td > < td class = "benchmarkresult" > 145< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.47< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 4.41< / td > < td class = "benchmarkresult" > 4.67< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.12< / td > < td class = "benchmarkresult" > 4.80< / td > < td class = "benchmarkresult" > 4.39< / td > < td class = "benchmarkresult" > 5.36< / td > < td class = "benchmarkresult" > 9.30< / td > < td class = "benchmarkresult" > 16.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.98< / td > < td class = "benchmarkresult" > 4.97< / td > < td class = "benchmarkresult" > 4.40< / td > < td class = "benchmarkresult" > 5.23< / td > < td class = "benchmarkresult" > 9.29< / td > < td class = "benchmarkresult" > 16.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.45< / td > < td class = "benchmarkresult" > 4.42< / td > < td class = "benchmarkresult" > 4.15< / td > < td class = "benchmarkresult" > 5.19< / td > < td class = "benchmarkresult" > 9.52< / td > < td class = "benchmarkresult" > 16.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.66< / td > < td class = "benchmarkresult" > 4.72< / td > < td class = "benchmarkresult" > 4.19< / td > < td class = "benchmarkresult" > 8.30< / td > < td class = "benchmarkresult" > 12.3< / td > < td class = "benchmarkresult" > 20.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.03< / td > < td class = "benchmarkresult" > 6.10< / td > < td class = "benchmarkresult" > 5.94< / td > < td class = "benchmarkresult" > 8.01< / td > < td class = "benchmarkresult" > 12.0< / td > < td class = "benchmarkresult" > 20.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.41< / td > < td class = "benchmarkresult" > 6.39< / td > < td class = "benchmarkresult" > 5.93< / td > < td class = "benchmarkresult" > 8.45< / td > < td class = "benchmarkresult" > 13.0< / 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.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.85< / td > < td class = "benchmarkresult" > 8.09< / td > < td class = "benchmarkresult" > 7.87< / td > < td class = "benchmarkresult" > 9.56< / td > < td class = "benchmarkresult" > 13.8< / td > < td class = "benchmarkresult" > 21.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
allocation or atomic increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 10.6< / td > < td class = "benchmarkresult" > 10.5< / td > < td class = "benchmarkresult" > 10.2< / td > < td class = "benchmarkresult" > 11.0< / td > < td class = "benchmarkresult" > 15.3< / td > < td class = "benchmarkresult" > 24.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
And then it's like everyone else.< / span > < / span > < / td > < td class = "benchmarkresult" > 98.1< / td > < td class = "benchmarkresult" > 51.8< / td > < td class = "benchmarkresult" > 97.0< / td > < td class = "benchmarkresult" > 98.2< / td > < td class = "benchmarkresult" > 95.2< / td > < td class = "benchmarkresult" > 82.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 73.1< / td > < td class = "benchmarkresult" > 105< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 103< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L798" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 86.2< / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 185< / td > < td class = "benchmarkresult" > 195< / td > < td class = "benchmarkresult" > 152< / 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-27 20:05:49 +00:00
{name:'std::string copy{str_with_len_N};/15',data:[5.24,1.17,4.85,1.90,5.09,45.0]},
{name:'std::string copy{str_with_len_N};/16',data:[23.2,1.22,27.2,79.1,82.6,51.9]},
{name:'std::string copy{str_with_len_N};/23',data:[27.4,23.9,27.7,77.6,83.1,48.6]},
{name:'std::string copy{str_with_len_N};/24',data:[22.6,24.6,21.2,78.3,83.0,49.6]},
{name:'std::string copy{str_with_len_N};/32',data:[22.1,23.8,22.3,81.9,85.5,53.9]},
{name:'std::string copy{str_with_len_N};/64',data:[22.2,25.7,23.2,80.8,90.0,52.8]},
{name:'std::string copy{str_with_len_N};/128',data:[24.7,26.5,28.4,84.0,89.5,59.2]},
{name:'std::string copy{str_with_len_N};/256',data:[24.8,27.7,25.2,86.9,91.4,77.3]},
{name:'std::string copy{str_with_len_N};/512',data:[29.1,31.2,27.8,89.8,93.4,86.0]},
{name:'std::string copy{str_with_len_N};/1024',data:[47.8,38.2,35.5,97.2,98.8,106]},
{name:'std::string copy{str_with_len_N};/2048',data:[123,86.4,118,126,132,119]},
{name:'std::string copy{str_with_len_N};/4096',data:[146,115,154,180,181,165]},
{name:'stringa copy{str_with_len_N};/15',data:[1.11,1.10,1.10,1.07,4.03,2.50]},
{name:'stringa copy{str_with_len_N};/16',data:[1.11,1.14,1.12,1.08,4.07,4.92]},
{name:'stringa copy{str_with_len_N};/23',data:[1.12,1.11,1.10,1.08,3.99,4.77]},
{name:'stringa copy{str_with_len_N};/24',data:[16.3,16.0,16.1,15.8,18.4,4.73]},
{name:'stringa copy{str_with_len_N};/32',data:[16.1,16.0,16.1,15.9,18.4,4.77]},
{name:'stringa copy{str_with_len_N};/64',data:[16.1,16.1,16.1,15.8,18.4,4.76]},
{name:'stringa copy{str_with_len_N};/128',data:[15.9,16.2,16.0,15.8,18.4,4.74]},
{name:'stringa copy{str_with_len_N};/256',data:[16.0,16.3,16.0,15.8,18.7,4.74]},
{name:'stringa copy{str_with_len_N};/512',data:[16.1,16.0,16.0,15.8,18.5,4.75]},
{name:'stringa copy{str_with_len_N};/1024',data:[16.0,16.0,16.0,15.8,18.5,4.75]},
{name:'stringa copy{str_with_len_N};/2048',data:[16.1,16.2,15.9,15.8,18.4,5.34]},
{name:'stringa copy{str_with_len_N};/4096',data:[16.0,16.0,16.1,15.8,18.4,5.09]},
{name:'lstringa< 16 > copy{str_with_len_N};/15',data:[1.11,1.13,1.47,1.10,4.55,4.26]},
{name:'lstringa< 16 > copy{str_with_len_N};/16',data:[5.42,5.27,4.43,4.79,9.64,16.3]},
{name:'lstringa< 16 > copy{str_with_len_N};/23',data:[5.17,5.22,4.43,4.81,9.66,36.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/24',data:[23.2,23.1,23.3,77.2,82.0,37.9]},
{name:'lstringa< 16 > copy{str_with_len_N};/32',data:[23.1,22.8,24.0,80.7,83.4,39.6]},
{name:'lstringa< 16 > copy{str_with_len_N};/64',data:[24.9,24.2,25.3,77.3,84.9,39.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/128',data:[24.9,23.9,40.0,83.4,88.6,39.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/256',data:[27.3,26.8,27.0,86.6,88.4,63.9]},
{name:'lstringa< 16 > copy{str_with_len_N};/512',data:[29.8,29.0,29.1,88.1,91.7,71.1]},
{name:'lstringa< 16 > copy{str_with_len_N};/1024',data:[95.4,78.3,97.4,94.7,95.5,84.9]},
{name:'lstringa< 16 > copy{str_with_len_N};/2048',data:[105,74.6,107,126,126,104]},
{name:'lstringa< 16 > copy{str_with_len_N};/4096',data:[122,89.5,121,191,186,145]},
{name:'lstringa< 512 > copy{str_with_len_N};/15',data:[1.13,1.14,1.47,1.10,4.41,4.67]},
{name:'lstringa< 512 > copy{str_with_len_N};/16',data:[5.12,4.80,4.39,5.36,9.30,16.9]},
{name:'lstringa< 512 > copy{str_with_len_N};/23',data:[4.98,4.97,4.40,5.23,9.29,16.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/24',data:[4.45,4.42,4.15,5.19,9.52,16.0]},
{name:'lstringa< 512 > copy{str_with_len_N};/32',data:[4.66,4.72,4.19,8.30,12.3,20.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/64',data:[6.03,6.10,5.94,8.01,12.0,20.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/128',data:[6.41,6.39,5.93,8.45,13.0,20.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/256',data:[7.85,8.09,7.87,9.56,13.8,21.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/512',data:[10.6,10.5,10.2,11.0,15.3,24.0]},
{name:'lstringa< 512 > copy{str_with_len_N};/1024',data:[98.1,51.8,97.0,98.2,95.2,82.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/2048',data:[104,73.1,105,132,129,103]},
{name:'lstringa< 512 > copy{str_with_len_N};/4096',data:[121,86.2,123,185,195,152]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L813" > 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-27 20:05:49 +00:00
Here, I attempted to run tests that are similar in logic to std::from_chars.< / span > < / span > < / td > < td class = "benchmarkresult" > 27.4< / td > < td class = "benchmarkresult" > 27.0< / td > < td class = "benchmarkresult" > 26.3< / td > < td class = "benchmarkresult" > 30.7< / td > < td class = "benchmarkresult" > 34.4< / td > < td class = "benchmarkresult" > 96.0< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L852" > 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-27 20:05:49 +00:00
signs, spaces, 0x prefixes, etc.< / span > < / span > < / td > < td class = "benchmarkresult" > 13.5< / td > < td class = "benchmarkresult" > 17.0< / td > < td class = "benchmarkresult" > 11.5< / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 12.6< / td > < td class = "benchmarkresult" > 0.787< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L880" > 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-27 20:05:49 +00:00
decimal system, no leading spaces, and no plus sign.< / span > < / span > < / td > < td class = "benchmarkresult" > 9.15< / td > < td class = "benchmarkresult" > 9.41< / td > < td class = "benchmarkresult" > 16.5< / td > < td class = "benchmarkresult" > 13.8< / td > < td class = "benchmarkresult" > 17.7< / td > < td class = "benchmarkresult" > 19.6< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L880" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.46< / td > < td class = "benchmarkresult" > 9.40< / td > < td class = "benchmarkresult" > 7.41< / td > < td class = "benchmarkresult" > 9.19< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 20.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L880" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.30< / td > < td class = "benchmarkresult" > 9.44< / td > < td class = "benchmarkresult" > 7.43< / td > < td class = "benchmarkresult" > 13.6< / td > < td class = "benchmarkresult" > 14.8< / td > < td class = "benchmarkresult" > 16.6< / 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-27 20:05:49 +00:00
{name:'std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);',data:[27.4,27.0,26.3,30.7,34.4,96.0]},
{name:'std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);',data:[13.5,17.0,11.5,12.5,12.6,0.787]},
{name:'stringa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.15,9.41,16.5,13.8,17.7,19.6]},
{name:'ssa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.46,9.40,7.41,9.19,16.3,20.8]},
{name:'lstringa< 20 > s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[9.30,9.44,7.43,13.6,14.8,16.6]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L826" > 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-27 20:05:49 +00:00
Everything is the same, only for the hexadecimal system< / span > < / span > < / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 23.3< / td > < td class = "benchmarkresult" > 23.6< / td > < td class = "benchmarkresult" > 33.4< / td > < td class = "benchmarkresult" > 34.5< / td > < td class = "benchmarkresult" > 69.8< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L866" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.22< / td > < td class = "benchmarkresult" > 21.9< / td > < td class = "benchmarkresult" > 8.89< / td > < td class = "benchmarkresult" > 8.02< / td > < td class = "benchmarkresult" > 8.74< / td > < td class = "benchmarkresult" > 19.3< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L895" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.60< / td > < td class = "benchmarkresult" > 7.71< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 12.7< / td > < td class = "benchmarkresult" > 14.2< / td > < td class = "benchmarkresult" > 20.2< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L895" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.56< / td > < td class = "benchmarkresult" > 7.62< / td > < td class = "benchmarkresult" > 6.35< / td > < td class = "benchmarkresult" > 7.26< / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 20.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L895" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.35< / td > < td class = "benchmarkresult" > 7.41< / td > < td class = "benchmarkresult" > 6.32< / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 15.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 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-27 20:05:49 +00:00
{name:'std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);',data:[24.0,23.3,23.6,33.4,34.5,69.8]},
{name:'std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);',data:[9.22,21.9,8.89,8.02,8.74,19.3]},
{name:'stringa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.60,7.71,15.8,12.7,14.2,20.2]},
{name:'ssa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.56,7.62,6.35,7.26,13.1,20.1]},
{name:'lstringa< 20 > s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[7.35,7.41,6.32,12.5,12.5,15.9]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L839" > 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-27 20:05:49 +00:00
And here we have parsing of an arbitrary number.< / span > < / span > < / td > < td class = "benchmarkresult" > 29.0< / td > < td class = "benchmarkresult" > 28.6< / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 43.9< / td > < td class = "benchmarkresult" > 45.5< / td > < td class = "benchmarkresult" > 98.1< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L910" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 11.1< / td > < td class = "benchmarkresult" > 11.1< / td > < td class = "benchmarkresult" > 22.9< / td > < td class = "benchmarkresult" > 18.1< / td > < td class = "benchmarkresult" > 22.0< / td > < td class = "benchmarkresult" > 13.9< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L925" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 13.3< / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 10.7< / td > < td class = "benchmarkresult" > 13.5< / td > < td class = "benchmarkresult" > 18.7< / td > < td class = "benchmarkresult" > 14.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 i n t \ ' 1 2 3 4 5 6 7 \ ' ' ] = { i d : ' b s 1 8 ' , t e s t s : [
2026-02-27 20:05:49 +00:00
{name:'std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);',data:[29.0,28.6,28.5,43.9,45.5,98.1]},
{name:'stringa s = " 123456789"; int res = s.to_int< int > ; // Check overflow',data:[11.1,11.1,22.9,18.1,22.0,13.9]},
{name:'ssa s = " 123456789"; int res = s.to_int< int , false > ; // No check overflow',data:[13.3,13.1,10.7,13.5,18.7,14.8]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L955" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 63.6< / td > < td class = "benchmarkresult" > 66.6< / td > < td class = "benchmarkresult" > 63.5< / td > < td class = "benchmarkresult" > 97.1< / td > < td class = "benchmarkresult" > 99.9< / td > < td class = "benchmarkresult" > 305< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L972" > std::string_view s = " 1234.567e10" ; std::from_chars(s.data(), s.data() + s.size(), res);< / a > < span class = "tooltiptext code" > template< typename K = char>
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;
2026-02-27 20:05:49 +00:00
if constexpr (requires { std::from_chars(std::declval< K*>(), std::declval< K*>(), std::declval< double& >()); }) {
if (std::from_chars((const K*)s.data(), (const K*)s.data() + s.size(), res).ec != std::errc{}) {
state.SkipWithError(" not equal" );
}
} else {
state.SkipWithError(" not implemented" );
2025-11-26 19:15:50 +00:00
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.1< / td > < td class = "benchmarkresult" > Not impl< / td > < td class = "benchmarkresult" > 23.8< / td > < td class = "benchmarkresult" > 61.6< / td > < td class = "benchmarkresult" > 85.0< / td > < td class = "benchmarkresult" > 106< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L993" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 26.0< / td > < td class = "benchmarkresult" > 34.2< / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 36.6< / td > < td class = "benchmarkresult" > 37.0< / td > < td class = "benchmarkresult" > 44.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 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-27 20:05:49 +00:00
{name:'std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);',data:[63.6,66.6,63.5,97.1,99.9,305]},
{name:'std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);',data:[24.1,NaN,23.8,61.6,85.0,106]},
{name:'ssa s = "1234.567e10"; double res = *s.to_double()',data:[26.0,34.2,24.2,36.6,37.0,44.4]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1017" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1374< / td > < td class = "benchmarkresult" > 1948< / td > < td class = "benchmarkresult" > 1379< / td > < td class = "benchmarkresult" > 4646< / td > < td class = "benchmarkresult" > 5668< / td > < td class = "benchmarkresult" > 6891< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1036" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 445< / td > < td class = "benchmarkresult" > 419< / td > < td class = "benchmarkresult" > 380< / td > < td class = "benchmarkresult" > 1060< / td > < td class = "benchmarkresult" > 1286< / td > < td class = "benchmarkresult" > 853< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1052" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 413< / td > < td class = "benchmarkresult" > 381< / td > < td class = "benchmarkresult" > 360< / td > < td class = "benchmarkresult" > 777< / td > < td class = "benchmarkresult" > 929< / td > < td class = "benchmarkresult" > 805< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1052" > 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-27 20:05:49 +00:00
required, and the faster the result.< / span > < / span > < / td > < td class = "benchmarkresult" > 289< / td > < td class = "benchmarkresult" > 279< / td > < td class = "benchmarkresult" > 263< / td > < td class = "benchmarkresult" > 399< / td > < td class = "benchmarkresult" > 539< / td > < td class = "benchmarkresult" > 594< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1052" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 248< / td > < td class = "benchmarkresult" > 253< / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 269< / td > < td class = "benchmarkresult" > 350< / td > < td class = "benchmarkresult" > 462< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1052" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 143< / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 227< / td > < td class = "benchmarkresult" > 366< / 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-27 20:05:49 +00:00
{name:'std::stringstream str; ... str < < "abbaabbaabbaabba";',data:[1374,1948,1379,4646,5668,6891]},
{name:'std::string str; ... str += "abbaabbaabbaabba";',data:[445,419,380,1060,1286,853]},
{name:'lstringa< 8 > str; ... str += "abbaabbaabbaabba";',data:[413,381,360,777,929,805]},
{name:'lstringa< 128 > str; ... str += "abbaabbaabbaabba";',data:[289,279,263,399,539,594]},
{name:'lstringa< 512 > str; ... str += "abbaabbaabbaabba";',data:[248,253,219,269,350,462]},
{name:'lstringa< 1024 > str; ... str += "abbaabbaabbaabba";',data:[139,157,143,157,227,366]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1077" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1439< / td > < td class = "benchmarkresult" > 1961< / td > < td class = "benchmarkresult" > 1348< / td > < td class = "benchmarkresult" > 4596< / td > < td class = "benchmarkresult" > 5590< / td > < td class = "benchmarkresult" > 7083< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1097" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1289< / td > < td class = "benchmarkresult" > 1263< / td > < td class = "benchmarkresult" > 1202< / td > < td class = "benchmarkresult" > 3781< / td > < td class = "benchmarkresult" > 3966< / td > < td class = "benchmarkresult" > 2327< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1115" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 443< / td > < td class = "benchmarkresult" > 467< / td > < td class = "benchmarkresult" > 456< / td > < td class = "benchmarkresult" > 726< / td > < td class = "benchmarkresult" > 829< / td > < td class = "benchmarkresult" > 1069< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1115" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 383< / td > < td class = "benchmarkresult" > 355< / td > < td class = "benchmarkresult" > 401< / td > < td class = "benchmarkresult" > 465< / td > < td class = "benchmarkresult" > 535< / td > < td class = "benchmarkresult" > 895< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1115" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 332< / td > < td class = "benchmarkresult" > 317< / td > < td class = "benchmarkresult" > 310< / td > < td class = "benchmarkresult" > 289< / td > < td class = "benchmarkresult" > 377< / td > < td class = "benchmarkresult" > 800< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1115" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 206< / td > < td class = "benchmarkresult" > 230< / td > < td class = "benchmarkresult" > 212< / td > < td class = "benchmarkresult" > 217< / td > < td class = "benchmarkresult" > 281< / td > < td class = "benchmarkresult" > 713< / 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-27 20:05:49 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; ' , data: [ 1439 , 1961 , 1348 , 4596 , 5590 , 7083 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba";',data:[1289,1263,1202,3781,3966,2327]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba";',data:[443,467,456,726,829,1069]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba";',data:[383,355,401,465,535,895]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba";',data:[332,317,310,289,377,800]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba";',data:[206,230,212,217,281,713]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1143" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 76125< / td > < td class = "benchmarkresult" > 140567< / td > < td class = "benchmarkresult" > 73026< / td > < td class = "benchmarkresult" > 215409< / td > < td class = "benchmarkresult" > 287657< / td > < td class = "benchmarkresult" > 345299< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1163" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 71507< / td > < td class = "benchmarkresult" > 94630< / td > < td class = "benchmarkresult" > 66199< / td > < td class = "benchmarkresult" > 193253< / td > < td class = "benchmarkresult" > 196942< / td > < td class = "benchmarkresult" > 127979< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1181" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 18029< / td > < td class = "benchmarkresult" > 43021< / td > < td class = "benchmarkresult" > 22156< / td > < td class = "benchmarkresult" > 18926< / td > < td class = "benchmarkresult" > 26361< / td > < td class = "benchmarkresult" > 52828< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1181" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15997< / td > < td class = "benchmarkresult" > 23822< / td > < td class = "benchmarkresult" > 18805< / td > < td class = "benchmarkresult" > 17170< / td > < td class = "benchmarkresult" > 23270< / td > < td class = "benchmarkresult" > 49507< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1181" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15776< / td > < td class = "benchmarkresult" > 18156< / td > < td class = "benchmarkresult" > 18433< / td > < td class = "benchmarkresult" > 15955< / td > < td class = "benchmarkresult" > 21890< / td > < td class = "benchmarkresult" > 50433< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1181" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 18991< / td > < td class = "benchmarkresult" > 17874< / td > < td class = "benchmarkresult" > 18781< / td > < td class = "benchmarkresult" > 17528< / td > < td class = "benchmarkresult" > 22257< / td > < td class = "benchmarkresult" > 47948< / 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-27 20:05:49 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; 2048 times ' , data: [ 76125 , 140567 , 73026 , 215409 , 287657 , 345299 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[71507,94630,66199,193253,196942,127979]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[18029,43021,22156,18926,26361,52828]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[15997,23822,18805,17170,23270,49507]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[15776,18156,18433,15955,21890,50433]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[18991,17874,18781,17528,22257,47948]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1208" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1364< / td > < td class = "benchmarkresult" > 2003< / td > < td class = "benchmarkresult" > 1378< / td > < td class = "benchmarkresult" > 4397< / td > < td class = "benchmarkresult" > 5535< / td > < td class = "benchmarkresult" > 7228< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1230" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1342< / td > < td class = "benchmarkresult" > 1370< / td > < td class = "benchmarkresult" > 1285< / td > < td class = "benchmarkresult" > 3970< / td > < td class = "benchmarkresult" > 4014< / td > < td class = "benchmarkresult" > 2636< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1251" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 523< / td > < td class = "benchmarkresult" > 496< / td > < td class = "benchmarkresult" > 532< / td > < td class = "benchmarkresult" > 812< / td > < td class = "benchmarkresult" > 924< / td > < td class = "benchmarkresult" > 1283< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1251" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 443< / td > < td class = "benchmarkresult" > 434< / td > < td class = "benchmarkresult" > 474< / td > < td class = "benchmarkresult" > 514< / td > < td class = "benchmarkresult" > 607< / td > < td class = "benchmarkresult" > 1173< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1251" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 409< / td > < td class = "benchmarkresult" > 387< / td > < td class = "benchmarkresult" > 379< / td > < td class = "benchmarkresult" > 383< / td > < td class = "benchmarkresult" > 471< / td > < td class = "benchmarkresult" > 1019< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1251" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 306< / td > < td class = "benchmarkresult" > 290< / td > < td class = "benchmarkresult" > 281< / td > < td class = "benchmarkresult" > 286< / td > < td class = "benchmarkresult" > 355< / td > < td class = "benchmarkresult" > 906< / 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-27 20:05:49 +00:00
{name:'std::stringstream str; ... str < < str_var1 < < str_var2 ; ' , data: [ 1364 , 2003 , 1378 , 4397 , 5535 , 7228 ] } ,
{name:'std::string str; ... str += str_var1 + str_var2;',data:[1342,1370,1285,3970,4014,2636]},
{name:'lstringa< 16 > str; ... str += str_var1 + str_var2;',data:[523,496,532,812,924,1283]},
{name:'lstringa< 128 > str; ... str += str_var1 + str_var2;',data:[443,434,474,514,607,1173]},
{name:'lstringa< 512 > str; ... str += str_var1 + str_var2;',data:[409,387,379,383,471,1019]},
{name:'lstringa< 1024 > str; ... str += str_var1 + str_var2;',data:[306,290,281,286,355,906]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1280" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3115< / td > < td class = "benchmarkresult" > 3322< / td > < td class = "benchmarkresult" > 2931< / td > < td class = "benchmarkresult" > 10543< / td > < td class = "benchmarkresult" > 11311< / td > < td class = "benchmarkresult" > 11660< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1298" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 437< / td > < td class = "benchmarkresult" > 475< / td > < td class = "benchmarkresult" > 412< / td > < td class = "benchmarkresult" > 1088< / td > < td class = "benchmarkresult" > 1258< / td > < td class = "benchmarkresult" > 1723< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1314" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1382< / td > < td class = "benchmarkresult" > 1200< / td > < td class = "benchmarkresult" > 1435< / td > < td class = "benchmarkresult" > 2743< / td > < td class = "benchmarkresult" > 2797< / td > < td class = "benchmarkresult" > 5394< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1332" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1121< / td > < td class = "benchmarkresult" > 948< / td > < td class = "benchmarkresult" > 1165< / td > < td class = "benchmarkresult" > 1919< / td > < td class = "benchmarkresult" > 2370< / td > < td class = "benchmarkresult" > 2892< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1348" > 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-27 20:05:49 +00:00
string without allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 1269< / td > < td class = "benchmarkresult" > 2019< / td > < td class = "benchmarkresult" > 1487< / td > < td class = "benchmarkresult" > 1972< / td > < td class = "benchmarkresult" > 2624< / td > < td class = "benchmarkresult" > 4873< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1348" > 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-27 20:05:49 +00:00
And it fits in this one. Use buffers of the appropriate size right away.< / span > < / span > < / td > < td class = "benchmarkresult" > 967< / td > < td class = "benchmarkresult" > 1714< / td > < td class = "benchmarkresult" > 1005< / td > < td class = "benchmarkresult" > 993< / td > < td class = "benchmarkresult" > 1513< / td > < td class = "benchmarkresult" > 4141< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1366" > 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-27 20:05:49 +00:00
The result does not fit into SSO, an allocation occurs.< / span > < / span > < / td > < td class = "benchmarkresult" > 278< / td > < td class = "benchmarkresult" > 271< / td > < td class = "benchmarkresult" > 289< / td > < td class = "benchmarkresult" > 810< / td > < td class = "benchmarkresult" > 877< / td > < td class = "benchmarkresult" > 611< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1366" > 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-27 20:05:49 +00:00
Once again, use appropriately sized buffers from the start.< / span > < / span > < / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 171< / td > < td class = "benchmarkresult" > 374< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1366" > 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-27 20:05:49 +00:00
enough to accommodate the result, hence the long time.< / span > < / span > < / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 136< / td > < td class = "benchmarkresult" > 118< / td > < td class = "benchmarkresult" > 172< / td > < td class = "benchmarkresult" > 554< / 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-27 20:05:49 +00:00
{name:'std::stringstream str; str < < "test = " < < k < < " times " ; ' , data: [ 3115 , 3322 , 2931 , 10543 , 11311 , 11660 ] } ,
{name:'std::string str = "test = " + std::to_string(k) + " times";',data:[437,475,412,1088,1258,1723]},
{name:'char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;',data:[1382,1200,1435,2743,2797,5394]},
{name:'std::string str = std::format("test = {} times", k);',data:[1121,948,1165,1919,2370,2892]},
{name:'lstringa< 8 > str; str.format("test = {} times", k);',data:[1269,2019,1487,1972,2624,4873]},
{name:'lstringa< 32 > str; str.format("test = {} times", k);',data:[967,1714,1005,993,1513,4141]},
{name:'lstringa< 8 > str = "test = " + k + " times";',data:[278,271,289,810,877,611]},
{name:'lstringa< 32 > str = "test = " + k + " times";',data:[120,120,132,129,171,374]},
{name:'stringa str = "test = " + k + " times";',data:[121,124,136,118,172,554]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1396" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 291< / td > < td class = "benchmarkresult" > 277< / td > < td class = "benchmarkresult" > 272< / td > < td class = "benchmarkresult" > 547< / td > < td class = "benchmarkresult" > 555< / td > < td class = "benchmarkresult" > 684< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1420" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 159< / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 306< / td > < td class = "benchmarkresult" > 247< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1437" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 201< / td > < td class = "benchmarkresult" > 211< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 212< / td > < td class = "benchmarkresult" > 284< / 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-27 20:05:49 +00:00
{name:'std::string::find + substr + std::strtol',data:[291,277,272,547,555,684]},
{name:'ssa::splitter + ssa::as_int',data:[159,153,190,167,306,247]},
{name:'ssa::splitf + functor',data:[201,211,194,194,212,284]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1458" > 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-27 20:05:49 +00:00
it works quickly.< / span > < / span > < / td > < td class = "benchmarkresult" > 826< / td > < td class = "benchmarkresult" > 892< / td > < td class = "benchmarkresult" > 793< / td > < td class = "benchmarkresult" > 1076< / td > < td class = "benchmarkresult" > 1249< / td > < td class = "benchmarkresult" > 2994< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1512" > 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-27 20:05:49 +00:00
conflicting replacements.< / span > < / span > < / td > < td class = "benchmarkresult" > 2450< / td > < td class = "benchmarkresult" > 2193< / td > < td class = "benchmarkresult" > 2390< / td > < td class = "benchmarkresult" > 1899< / td > < td class = "benchmarkresult" > 2111< / td > < td class = "benchmarkresult" > 5651< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1566" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1073< / td > < td class = "benchmarkresult" > 1024< / td > < td class = "benchmarkresult" > 960< / td > < td class = "benchmarkresult" > 2272< / td > < td class = "benchmarkresult" > 2522< / td > < td class = "benchmarkresult" > 2910< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1619" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1247< / td > < td class = "benchmarkresult" > 1463< / td > < td class = "benchmarkresult" > 1320< / td > < td class = "benchmarkresult" > 1591< / td > < td class = "benchmarkresult" > 1682< / td > < td class = "benchmarkresult" > 2879< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1619" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 959< / td > < td class = "benchmarkresult" > 1131< / td > < td class = "benchmarkresult" > 1012< / td > < td class = "benchmarkresult" > 1349< / td > < td class = "benchmarkresult" > 1470< / td > < td class = "benchmarkresult" > 2251< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1666" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1104< / td > < td class = "benchmarkresult" > 1003< / td > < td class = "benchmarkresult" > 1057< / td > < td class = "benchmarkresult" > 1129< / td > < td class = "benchmarkresult" > 1271< / td > < td class = "benchmarkresult" > 2457< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1666" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 804< / td > < td class = "benchmarkresult" > 876< / td > < td class = "benchmarkresult" > 827< / td > < td class = "benchmarkresult" > 1182< / td > < td class = "benchmarkresult" > 1209< / td > < td class = "benchmarkresult" > 2073< / 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-27 20:05:49 +00:00
{name:'Naive (and wrong) replace symbols with std::string find + replace',data:[826,892,793,1076,1249,2994]},
{name:'replace symbols with std::string find_first_of + replace',data:[2450,2193,2390,1899,2111,5651]},
{name:'replace symbols with std::string_view find_first_of + copy',data:[1073,1024,960,2272,2522,2910]},
{name:'replace runtime symbols with string expressions and without remembering all search results',data:[1247,1463,1320,1591,1682,2879]},
{name:'replace runtime symbols with simstr and memorization of all search results',data:[959,1131,1012,1349,1470,2251]},
{name:'replace const symbols with string expressions and without remembering all search results',data:[1104,1003,1057,1129,1271,2457]},
{name:'replace const symbols with string expressions and memorization of all search results',data:[804,876,827,1182,1209,2073]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1720" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 158< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 299< / td > < td class = "benchmarkresult" > 327< / td > < td class = "benchmarkresult" > 498< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1760" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 311< / td > < td class = "benchmarkresult" > 309< / td > < td class = "benchmarkresult" > 318< / td > < td class = "benchmarkresult" > 346< / td > < td class = "benchmarkresult" > 407< / td > < td class = "benchmarkresult" > 751< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1800" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 152< / td > < td class = "benchmarkresult" > 150< / td > < td class = "benchmarkresult" > 296< / td > < td class = "benchmarkresult" > 339< / td > < td class = "benchmarkresult" > 448< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1839" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 166< / td > < td class = "benchmarkresult" > 192< / td > < td class = "benchmarkresult" > 175< / td > < td class = "benchmarkresult" > 266< / td > < td class = "benchmarkresult" > 309< / td > < td class = "benchmarkresult" > 392< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1839" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 174< / td > < td class = "benchmarkresult" > 208< / td > < td class = "benchmarkresult" > 178< / td > < td class = "benchmarkresult" > 357< / td > < td class = "benchmarkresult" > 387< / td > < td class = "benchmarkresult" > 421< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1872" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 136< / td > < td class = "benchmarkresult" > 198< / td > < td class = "benchmarkresult" > 250< / td > < td class = "benchmarkresult" > 278< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1872" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 138< / td > < td class = "benchmarkresult" > 137< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 297< / td > < td class = "benchmarkresult" > 363< / td > < td class = "benchmarkresult" > 317< / 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-27 20:05:49 +00:00
{name:'Short Naive (and wrong) replace symbols with std::string find + replace',data:[158,167,157,299,327,498]},
{name:'Short replace symbols with std::string find_first_of + replace',data:[311,309,318,346,407,751]},
{name:'Short replace symbols with std::string_view find_first_of + copy',data:[154,152,150,296,339,448]},
{name:'Short replace runtime symbols with string expressions and without remembering all search results',data:[166,192,175,266,309,392]},
{name:'Short replace runtime symbols with simstr and memorization of all search results',data:[174,208,178,357,387,421]},
{name:'Short replace const symbols with string expressions and without remembering all search results',data:[127,124,136,198,250,278]},
{name:'Short replace const symbols with string expressions and memorization of all search results',data:[138,137,129,297,363,317]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1911" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 152< / td > < td class = "benchmarkresult" > 173< / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 221< / td > < td class = "benchmarkresult" > 239< / td > < td class = "benchmarkresult" > 370< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1911" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 525< / td > < td class = "benchmarkresult" > 844< / td > < td class = "benchmarkresult" > 500< / td > < td class = "benchmarkresult" > 737< / td > < td class = "benchmarkresult" > 755< / td > < td class = "benchmarkresult" > 1187< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1911" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1078< / td > < td class = "benchmarkresult" > 1199< / td > < td class = "benchmarkresult" > 972< / td > < td class = "benchmarkresult" > 1364< / td > < td class = "benchmarkresult" > 1467< / td > < td class = "benchmarkresult" > 2268< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1911" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2264< / td > < td class = "benchmarkresult" > 2462< / td > < td class = "benchmarkresult" > 2261< / td > < td class = "benchmarkresult" > 3034< / td > < td class = "benchmarkresult" > 3081< / td > < td class = "benchmarkresult" > 4800< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1911" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5910< / td > < td class = "benchmarkresult" > 6298< / td > < td class = "benchmarkresult" > 5887< / td > < td class = "benchmarkresult" > 7577< / td > < td class = "benchmarkresult" > 7858< / td > < td class = "benchmarkresult" > 10945< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1945" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 130< / td > < td class = "benchmarkresult" > 214< / td > < td class = "benchmarkresult" > 231< / td > < td class = "benchmarkresult" > 285< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1945" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 425< / td > < td class = "benchmarkresult" > 446< / td > < td class = "benchmarkresult" > 494< / td > < td class = "benchmarkresult" > 601< / td > < td class = "benchmarkresult" > 653< / td > < td class = "benchmarkresult" > 910< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1945" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 801< / td > < td class = "benchmarkresult" > 831< / td > < td class = "benchmarkresult" > 839< / td > < td class = "benchmarkresult" > 1009< / td > < td class = "benchmarkresult" > 1115< / td > < td class = "benchmarkresult" > 1712< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1945" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1639< / td > < td class = "benchmarkresult" > 1609< / td > < td class = "benchmarkresult" > 1731< / td > < td class = "benchmarkresult" > 1851< / td > < td class = "benchmarkresult" > 2048< / td > < td class = "benchmarkresult" > 3116< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1945" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3077< / td > < td class = "benchmarkresult" > 3058< / td > < td class = "benchmarkresult" > 3350< / td > < td class = "benchmarkresult" > 3468< / td > < td class = "benchmarkresult" > 3807< / td > < td class = "benchmarkresult" > 6042< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1968" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 92.5< / td > < td class = "benchmarkresult" > 89.4< / td > < td class = "benchmarkresult" > 82.3< / td > < td class = "benchmarkresult" > 161< / td > < td class = "benchmarkresult" > 197< / td > < td class = "benchmarkresult" > 170< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1968" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 293< / td > < td class = "benchmarkresult" > 283< / td > < td class = "benchmarkresult" > 276< / td > < td class = "benchmarkresult" > 362< / td > < td class = "benchmarkresult" > 448< / td > < td class = "benchmarkresult" > 586< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1968" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 687< / td > < td class = "benchmarkresult" > 673< / td > < td class = "benchmarkresult" > 675< / td > < td class = "benchmarkresult" > 773< / td > < td class = "benchmarkresult" > 1049< / td > < td class = "benchmarkresult" > 1275< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1968" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1581< / td > < td class = "benchmarkresult" > 1432< / td > < td class = "benchmarkresult" > 1510< / td > < td class = "benchmarkresult" > 1575< / td > < td class = "benchmarkresult" > 2172< / td > < td class = "benchmarkresult" > 2632< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1968" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3167< / td > < td class = "benchmarkresult" > 2854< / td > < td class = "benchmarkresult" > 3059< / td > < td class = "benchmarkresult" > 2876< / td > < td class = "benchmarkresult" > 4373< / td > < td class = "benchmarkresult" > 5701< / 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-27 20:05:49 +00:00
{name:'replace bb to ---- in std::string|64',data:[152,173,154,221,239,370]},
{name:'replace bb to ---- in std::string|256',data:[525,844,500,737,755,1187]},
{name:'replace bb to ---- in std::string|512',data:[1078,1199,972,1364,1467,2268]},
{name:'replace bb to ---- in std::string|1024',data:[2264,2462,2261,3034,3081,4800]},
{name:'replace bb to ---- in std::string|2048',data:[5910,6298,5887,7577,7858,10945]},
{name:'replace bb to ---- in lstringa< 8 > |64',data:[127,129,130,214,231,285]},
{name:'replace bb to ---- in lstringa< 8 > |256',data:[425,446,494,601,653,910]},
{name:'replace bb to ---- in lstringa< 8 > |512',data:[801,831,839,1009,1115,1712]},
{name:'replace bb to ---- in lstringa< 8 > |1024',data:[1639,1609,1731,1851,2048,3116]},
{name:'replace bb to ---- in lstringa< 8 > |2048',data:[3077,3058,3350,3468,3807,6042]},
{name:'replace bb to ---- by init stringa|64',data:[92.5,89.4,82.3,161,197,170]},
{name:'replace bb to ---- by init stringa|256',data:[293,283,276,362,448,586]},
{name:'replace bb to ---- by init stringa|512',data:[687,673,675,773,1049,1275]},
{name:'replace bb to ---- by init stringa|1024',data:[1581,1432,1510,1575,2172,2632]},
{name:'replace bb to ---- by init stringa|2048',data:[3167,2854,3059,2876,4373,5701]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1990" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 112< / td > < td class = "benchmarkresult" > 118< / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 178< / td > < td class = "benchmarkresult" > 196< / td > < td class = "benchmarkresult" > 264< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1990" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 376< / td > < td class = "benchmarkresult" > 413< / td > < td class = "benchmarkresult" > 365< / td > < td class = "benchmarkresult" > 459< / td > < td class = "benchmarkresult" > 503< / td > < td class = "benchmarkresult" > 846< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1990" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 720< / td > < td class = "benchmarkresult" > 825< / td > < td class = "benchmarkresult" > 772< / td > < td class = "benchmarkresult" > 828< / td > < td class = "benchmarkresult" > 898< / td > < td class = "benchmarkresult" > 1556< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1990" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1438< / td > < td class = "benchmarkresult" > 1543< / td > < td class = "benchmarkresult" > 1404< / td > < td class = "benchmarkresult" > 1549< / td > < td class = "benchmarkresult" > 1731< / td > < td class = "benchmarkresult" > 2961< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L1990" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2839< / td > < td class = "benchmarkresult" > 3140< / td > < td class = "benchmarkresult" > 2726< / td > < td class = "benchmarkresult" > 3072< / td > < td class = "benchmarkresult" > 3433< / td > < td class = "benchmarkresult" > 5794< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2023" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 93.2< / td > < td class = "benchmarkresult" > 88.1< / td > < td class = "benchmarkresult" > 90.0< / td > < td class = "benchmarkresult" > 173< / td > < td class = "benchmarkresult" > 185< / td > < td class = "benchmarkresult" > 198< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2023" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 297< / td > < td class = "benchmarkresult" > 282< / td > < td class = "benchmarkresult" > 295< / td > < td class = "benchmarkresult" > 426< / td > < td class = "benchmarkresult" > 442< / td > < td class = "benchmarkresult" > 663< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2023" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 519< / td > < td class = "benchmarkresult" > 526< / td > < td class = "benchmarkresult" > 540< / td > < td class = "benchmarkresult" > 727< / td > < td class = "benchmarkresult" > 765< / td > < td class = "benchmarkresult" > 1186< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2023" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1081< / td > < td class = "benchmarkresult" > 1072< / td > < td class = "benchmarkresult" > 1086< / td > < td class = "benchmarkresult" > 1381< / td > < td class = "benchmarkresult" > 1447< / td > < td class = "benchmarkresult" > 2250< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2023" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2117< / td > < td class = "benchmarkresult" > 2023< / td > < td class = "benchmarkresult" > 2111< / td > < td class = "benchmarkresult" > 2653< / td > < td class = "benchmarkresult" > 2826< / td > < td class = "benchmarkresult" > 4373< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2045" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 75.5< / td > < td class = "benchmarkresult" > 75.3< / td > < td class = "benchmarkresult" > 75.9< / td > < td class = "benchmarkresult" > 150< / td > < td class = "benchmarkresult" > 163< / td > < td class = "benchmarkresult" > 144< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2045" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 243< / td > < td class = "benchmarkresult" > 233< / td > < td class = "benchmarkresult" > 241< / td > < td class = "benchmarkresult" > 329< / td > < td class = "benchmarkresult" > 373< / td > < td class = "benchmarkresult" > 472< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2045" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 429< / td > < td class = "benchmarkresult" > 428< / td > < td class = "benchmarkresult" > 457< / td > < td class = "benchmarkresult" > 519< / td > < td class = "benchmarkresult" > 620< / td > < td class = "benchmarkresult" > 894< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2045" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 909< / td > < td class = "benchmarkresult" > 846< / td > < td class = "benchmarkresult" > 920< / td > < td class = "benchmarkresult" > 987< / td > < td class = "benchmarkresult" > 1101< / td > < td class = "benchmarkresult" > 1701< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2045" > 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-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1687< / td > < td class = "benchmarkresult" > 1654< / td > < td class = "benchmarkresult" > 1760< / td > < td class = "benchmarkresult" > 1744< / td > < td class = "benchmarkresult" > 2114< / td > < td class = "benchmarkresult" > 2793< / 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-27 20:05:49 +00:00
{name:'replace bb to -- in std::string|64',data:[112,118,120,178,196,264]},
{name:'replace bb to -- in std::string|256',data:[376,413,365,459,503,846]},
{name:'replace bb to -- in std::string|512',data:[720,825,772,828,898,1556]},
{name:'replace bb to -- in std::string|1024',data:[1438,1543,1404,1549,1731,2961]},
{name:'replace bb to -- in std::string|2048',data:[2839,3140,2726,3072,3433,5794]},
{name:'replace bb to -- in lstringa< 8 > |64',data:[93.2,88.1,90.0,173,185,198]},
{name:'replace bb to -- in lstringa< 8 > |256',data:[297,282,295,426,442,663]},
{name:'replace bb to -- in lstringa< 8 > |512',data:[519,526,540,727,765,1186]},
{name:'replace bb to -- in lstringa< 8 > |1024',data:[1081,1072,1086,1381,1447,2250]},
{name:'replace bb to -- in lstringa< 8 > |2048',data:[2117,2023,2111,2653,2826,4373]},
{name:'replace bb to -- by init stringa|64',data:[75.5,75.3,75.9,150,163,144]},
{name:'replace bb to -- by init stringa|256',data:[243,233,241,329,373,472]},
{name:'replace bb to -- by init stringa|512',data:[429,428,457,519,620,894]},
{name:'replace bb to -- by init stringa|1024',data:[909,846,920,987,1101,1701]},
{name:'replace bb to -- by init stringa|2048',data:[1687,1654,1760,1744,2114,2793]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2142" > 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-27 20:05:49 +00:00
hashStrMapA, and then search for them in it.< / span > < / span > < / td > < td class = "benchmarkresult" > 3719139< / td > < td class = "benchmarkresult" > 3677557< / td > < td class = "benchmarkresult" > 3672616< / td > < td class = "benchmarkresult" > 3865656< / td > < td class = "benchmarkresult" > 4373144< / td > < td class = "benchmarkresult" > 3509082< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2166" > 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-27 20:05:49 +00:00
Same thing with std::string and std::unordered_map< / span > < / span > < / td > < td class = "benchmarkresult" > 3546099< / td > < td class = "benchmarkresult" > 3517210< / td > < td class = "benchmarkresult" > 3585692< / td > < td class = "benchmarkresult" > 5706555< / td > < td class = "benchmarkresult" > 5795906< / td > < td class = "benchmarkresult" > 3684923< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2190" > 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-27 20:05:49 +00:00
Now we insert stringa and search for ssa< / span > < / span > < / td > < td class = "benchmarkresult" > 3596978< / td > < td class = "benchmarkresult" > 3630665< / td > < td class = "benchmarkresult" > 3715466< / td > < td class = "benchmarkresult" > 3462807< / td > < td class = "benchmarkresult" > 3917153< / td > < td class = "benchmarkresult" > 3369803< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2215" > 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-27 20:05:49 +00:00
We insert std::string and look for std::string_view< / span > < / span > < / td > < td class = "benchmarkresult" > 4271995< / td > < td class = "benchmarkresult" > 4042057< / td > < td class = "benchmarkresult" > 3948260< / td > < td class = "benchmarkresult" > 6453507< / td > < td class = "benchmarkresult" > 6341143< / td > < td class = "benchmarkresult" > 4260216< / 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-27 20:05:49 +00:00
{name:'hashStrMapA< size_t > emplace & find stringa;',data:[3719139,3677557,3672616,3865656,4373144,3509082]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string;',data:[3546099,3517210,3585692,5706555,5795906,3684923]},
{name:'hashStrMapA< size_t > emplace & find ssa;',data:[3596978,3630665,3715466,3462807,3917153,3369803]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string_view;',data:[4271995,4042057,3948260,6453507,6341143,4260216]}
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-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2425" > 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-27 20:05:49 +00:00
return values. The algorithm uses std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 652< / td > < td class = "benchmarkresult" > 991< / td > < td class = "benchmarkresult" > 733< / td > < td class = "benchmarkresult" > 1543< / td > < td class = "benchmarkresult" > 1574< / td > < td class = "benchmarkresult" > 3466< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2457" > 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-27 20:05:49 +00:00
+= to a string are replaced with a single += + + +.< / span > < / span > < / td > < td class = "benchmarkresult" > 722< / td > < td class = "benchmarkresult" > 997< / td > < td class = "benchmarkresult" > 789< / td > < td class = "benchmarkresult" > 1527< / td > < td class = "benchmarkresult" > 1638< / td > < td class = "benchmarkresult" > 3613< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2487" > 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-27 20:05:49 +00:00
We construct the function name through std::ostringstream and < < < / span > < / span > < / td > < td class = "benchmarkresult" > 2537< / td > < td class = "benchmarkresult" > 2832< / td > < td class = "benchmarkresult" > 2490< / td > < td class = "benchmarkresult" > 8122< / td > < td class = "benchmarkresult" > 9771< / td > < td class = "benchmarkresult" > 13169< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2398" > 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-27 20:05:49 +00:00
Parameter information is appended to the current line.< / span > < / span > < / td > < td class = "benchmarkresult" > 483< / td > < td class = "benchmarkresult" > 443< / td > < td class = "benchmarkresult" > 449< / td > < td class = "benchmarkresult" > 765< / td > < td class = "benchmarkresult" > 855< / td > < td class = "benchmarkresult" > 1567< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2413" > 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-27 20:05:49 +00:00
to be written in a single string, but is slightly slower in execution time.< / span > < / span > < / td > < td class = "benchmarkresult" > 599< / td > < td class = "benchmarkresult" > 597< / td > < td class = "benchmarkresult" > 530< / td > < td class = "benchmarkresult" > 852< / td > < td class = "benchmarkresult" > 988< / td > < td class = "benchmarkresult" > 1808< / 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-27 20:05:49 +00:00
{name:'Build func full name std::string;',data:[652,991,733,1543,1574,3466]},
{name:'Build func full name std::string 1;',data:[722,997,789,1527,1638,3613]},
{name:'Build func full name std::stream;',data:[2537,2832,2490,8122,9771,13169]},
{name:'Build func full name stringa;',data:[483,443,449,765,855,1567]},
{name:'Build func full name stringa 1;',data:[599,597,530,852,988,1808]}
2026-02-15 14:13:54 +00:00
]}< / script >
< div class = "benchset" id = "bs32" > < h4 > < a id = "bs36691618230457010710" href = "#bs36691618230457010710" > #< / a > Make Upper< / h4 >
2026-02-27 20:05:49 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-22 libc++< / th > < th width = "6%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-15< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, Clang-22< / th > < th width = "6%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "6%" > Xeon E5-2682 v4, WASM Chrome 143, Clang-22< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2627" > To upper case std::wstring< / a > < span class = "tooltiptext code" > void UpperCaseStd(benchmark::State& state) {
2026-02-15 14:13:54 +00:00
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
}
2026-02-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 150< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 1405< / td > < td class = "benchmarkresult" > 1404< / td > < td class = "benchmarkresult" > 226< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/rel1.7.2/bench/bench_str.cpp#L2647" > To upper case lstringw< 15>< / a > < span class = "tooltiptext code" > void UpperCaseSim(benchmark::State& state) {
2026-02-15 14:13:54 +00:00
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
}
2026-02-27 20:05:49 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 39.8< / td > < td class = "benchmarkresult" > 40.3< / td > < td class = "benchmarkresult" > 39.3< / td > < td class = "benchmarkresult" > 36.2< / td > < td class = "benchmarkresult" > 47.9< / td > < td class = "benchmarkresult" > 68.2< / td > < / tr >
2026-02-15 14:13:54 +00:00
< / 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 : [
2026-02-27 20:05:49 +00:00
{name:'To upper case std::wstring',data:[150,167,168,1405,1404,226]},
{name:'To upper case lstringw< 15 > ',data:[39.8,40.3,39.3,36.2,47.9,68.2]}
2025-11-26 19:15:50 +00:00
]}< / script > < / body > < / html >