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 >
< / head > < body > < div class = "header" > < h2 > SimStr benchmarks results< / h2 >
< span > All times in ns.< / span >
< span > < a href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp" > Source for benchmarks< / a > < / span >
< div > Group tests by platforms in charts: < input type = "checkbox" id = "gbp" checked onchange = "switchGrouping()" / > < / div > < div class = "test_platforms" > < h3 > Test configurations:< / h3 > < ul >
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-01-30 14:30:09 +00:00
Load Average: 0.01, 0.41, 0.63
2026-01-21 11:59:17 +00:00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl0" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-01-21 11:59:17 +00:00
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 = "pl1" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, Clang-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl2" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, MSVC-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl3" checked onchange = "buildCharts()" / > < / li >
2026-01-21 11:59:17 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / span > < span class = "tooltip" > 32 X 2513.96 MHz CPU s< span class = "tooltiptext" > Firefox: 146.0.1.60 webasm< / span > < / span > Include in charts: < input type = "checkbox" id = "pl4" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< / ul > < / div > < / div >
2026-01-21 11:59:17 +00:00
< script > const platform _names = [ 'Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21' , 'Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13' , 'Xeon E5-2682 v4, Windows 10, Clang-19' , 'Xeon E5-2682 v4, Windows 10, MSVC-19' , 'Xeon E5-2682 v4, WASM Firefox, Clang-21' ] ; < / script >
2025-04-05 14:21:11 +00:00
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs1" > < h4 > < a id = "bs70109915512075798510" href = "#bs70109915512075798510" > #< / a > Concatenate string + Number + " Literal" < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string and number by std to std::string< span class = "tooltiptext code" > void ConcatStdToStd(benchmark::State& state) {
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = s1 + std::to_string(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 201< / td > < td class = "benchmarkresult" > 263< / td > < td class = "benchmarkresult" > 314< / td > < td class = "benchmarkresult" > 947< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string and number by StrExpr to std::string< span class = "tooltiptext code" > void ConcatSimToStd(benchmark::State& state) {
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = +s1 + i + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 103< / td > < td class = "benchmarkresult" > 152< / td > < td class = "benchmarkresult" > 227< / td > < td class = "benchmarkresult" > 409< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat stringa and number by StrExpr to simstr::stringa< span class = "tooltiptext code" > void ConcatSimToSim(benchmark::State& state) {
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = s1 + i + " end" ;
benchmark::DoNotOptimize(str);
}
}
}< / 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-01-30 14:30:09 +00:00
while in stringa , the entire test is included in SSO.< / span > < / span > < / td > < td class = "benchmarkresult" > 65.4< / td > < td class = "benchmarkresult" > 73.7< / td > < td class = "benchmarkresult" > 67.5< / td > < td class = "benchmarkresult" > 112< / td > < td class = "benchmarkresult" > 225< / td > < / tr >
2026-01-29 20:48:41 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat stringa and number by e_concat to simstr::stringa< span class = "tooltiptext code" > void ConcatSimToSimConcat(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 72.6< / td > < td class = "benchmarkresult" > 85.7< / td > < td class = "benchmarkresult" > 74.8< / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 221< / td > < / tr >
2026-01-21 11:59:17 +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 1 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Concat std::string and number by std to std::string',data:[219,201,263,314,947]},
{name:'Concat std::string and number by StrExpr to std::string',data:[104,103,152,227,409]},
{name:'Concat stringa and number by StrExpr to simstr::stringa',data:[65.4,73.7,67.5,112,225]},
{name:'Concat stringa and number by e_concat to simstr::stringa',data:[72.6,85.7,74.8,116,221]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs2" > < h4 > < a id = "bs146911715078927772520" href = "#bs146911715078927772520" > #< / a > Concatenate string + Hex Number + " Literal" < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-01-30 14:30:09 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string and format hex number and literal to std::string< span class = "tooltiptext code" > void ConcatStdToFmtHex(benchmark::State& state) {
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = s1 + std::format(" {:#x}" , i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 686< / td > < td class = "benchmarkresult" > 660< / td > < td class = "benchmarkresult" > 717< / td > < td class = "benchmarkresult" > 1064< / td > < td class = "benchmarkresult" > 1426< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::format std::string and hex number by literal to std::string< span class = "tooltiptext code" > void ConcatAllFmtToHex(benchmark::State& state) {
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = std::format(" {}{:#x} end" , s1, i);
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 868< / td > < td class = "benchmarkresult" > 915< / td > < td class = "benchmarkresult" > 1502< / td > < td class = "benchmarkresult" > 1852< / td > < td class = "benchmarkresult" > 1603< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string and std::tochars and string to std::string< 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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 203< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 193< / td > < td class = "benchmarkresult" > 253< / td > < td class = "benchmarkresult" > 669< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string and hex number and literal by StrExpr to std::string< 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-01-21 11:59:17 +00:00
std::string str = +s1 + e_hex< HexFlags::Short>(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 80.5< / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 414< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat stringa and hex number and literal by StrExpr to simstr::stringa< 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-01-21 11:59:17 +00:00
stringa str = s1 + e_hex< HexFlags::Short>(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 72.0< / td > < td class = "benchmarkresult" > 105< / td > < td class = "benchmarkresult" > 208< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat stringa and hex number and literal by e_concat to simstr::stringa< 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-01-29 20:48:41 +00:00
stringa str = e_concat(" " , s1, e_hex< HexFlags::Short>(i), " end" );
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 117< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 81.6< / td > < td class = "benchmarkresult" > 106< / td > < td class = "benchmarkresult" > 219< / td > < / tr >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Subst stringa and hex number by e_subst literal to simstr::stringa< 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);
stringa str = e_subst(S_FRM(" {}{} end" ), s1, e_hex< HexFlags::Short>(i));
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 184< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 152< / td > < td class = "benchmarkresult" > 175< / td > < td class = "benchmarkresult" > 464< / td > < / tr >
2026-01-21 11:59:17 +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 2 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Concat std::string and format hex number and literal to std::string',data:[686,660,717,1064,1426]},
{name:'std::format std::string and hex number by literal to std::string',data:[868,915,1502,1852,1603]},
{name:'Concat std::string and std::tochars and string to std::string',data:[203,190,193,253,669]},
{name:'Concat std::string and hex number and literal by StrExpr to std::string',data:[132,124,80.5,114,414]},
{name:'Concat stringa and hex number and literal by StrExpr to simstr::stringa',data:[116,120,72.0,105,208]},
{name:'Concat stringa and hex number and literal by e_concat to simstr::stringa',data:[117,127,81.6,106,219]},
{name:'Subst stringa and hex number by e_subst literal to simstr::stringa',data:[184,167,152,175,464]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs3" > < h4 > < a id = "bs59672599204338055190" href = "#bs59672599204338055190" > #< / a > Concatenate string + " Literal" < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string by std to std::string< span class = "tooltiptext code" > void ConcatStdToStdS(benchmark::State& state) {
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 81.0< / td > < td class = "benchmarkresult" > 50.2< / td > < td class = "benchmarkresult" > 40.2< / td > < td class = "benchmarkresult" > 55.5< / td > < td class = "benchmarkresult" > 97.5< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat std::string by StrExpr to std::string< span class = "tooltiptext code" > void ConcatSimToStdS(benchmark::State& state) {
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = +s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 37.9< / td > < td class = "benchmarkresult" > 37.4< / td > < td class = "benchmarkresult" > 39.0< / td > < td class = "benchmarkresult" > 81.4< / td > < td class = "benchmarkresult" > 110< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat stringa by StrExpr to stringa< span class = "tooltiptext code" > void ConcatSimToSimS(benchmark::State& state) {
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 26.6< / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 52.3< / td > < td class = "benchmarkresult" > 96.3< / td > < / tr >
2026-01-21 11:59:17 +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 3 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Concat std::string by std to std::string',data:[81.0,50.2,40.2,55.5,97.5]},
{name:'Concat std::string by StrExpr to std::string',data:[37.9,37.4,39.0,81.4,110]},
{name:'Concat stringa by StrExpr to stringa',data:[31.0,26.6,28.5,52.3,96.3]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs4" > < h4 > < a id = "bs68116594352702954700" href = "#bs68116594352702954700" > #< / a > Find three concatenated string in string_view< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Find concat three std::string< span class = "tooltiptext code" > size_t find_pos_str(std::string_view src, std::string_view name) {
// before C++26 we can not concatenate string and string_view...
return src.find(" \n- " s + std::string{name} + " -\n" );
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 131< / td > < td class = "benchmarkresult" > 219< / td > < td class = "benchmarkresult" > 224< / td > < td class = "benchmarkresult" > 190< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Find concat three strexpr< span class = "tooltiptext code" > size_t find_pos_exp(ssa src, ssa name) {
return src.find(std::string{" \n- " + name + " -\n" });
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 52.9< / td > < td class = "benchmarkresult" > 41.2< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 125< / td > < td class = "benchmarkresult" > 106< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Find concat three simstr< span class = "tooltiptext code" > size_t find_pos_sim(ssa src, ssa name) {
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-01-30 14:30:09 +00:00
it is collected in a stack-based buffer, without allocation or deallocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 20.2< / td > < td class = "benchmarkresult" > 20.0< / td > < td class = "benchmarkresult" > 27.7< / td > < td class = "benchmarkresult" > 28.6< / td > < td class = "benchmarkresult" > 76.2< / td > < / tr >
2026-01-21 11:59:17 +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 4 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Find concat three std::string',data:[125,131,219,224,190]},
{name:'Find concat three strexpr',data:[52.9,41.2,132,125,106]},
{name:'Find concat three simstr',data:[20.2,20.0,27.7,28.6,76.2]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs5" > < h4 > < a id = "bs145290966789248325200" href = "#bs145290966789248325200" > #< / a > Build Type Name< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameStr 0/0< span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.31< / td > < td class = "benchmarkresult" > 10.0< / td > < td class = "benchmarkresult" > 8.25< / td > < td class = "benchmarkresult" > 18.2< / td > < td class = "benchmarkresult" > 18.1< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameExp 0/0< span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.86< / td > < td class = "benchmarkresult" > 6.30< / td > < td class = "benchmarkresult" > 7.79< / td > < td class = "benchmarkresult" > 12.7< / td > < td class = "benchmarkresult" > 17.7< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameSim 0/0< span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.96< / td > < td class = "benchmarkresult" > 4.85< / td > < td class = "benchmarkresult" > 7.83< / td > < td class = "benchmarkresult" > 16.7< / td > < td class = "benchmarkresult" > 16.7< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameStr 10/10< span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 57.6< / td > < td class = "benchmarkresult" > 77.6< / td > < td class = "benchmarkresult" > 63.1< / td > < td class = "benchmarkresult" > 80.2< / td > < td class = "benchmarkresult" > 282< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameExp 10/10< span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 26.2< / td > < td class = "benchmarkresult" > 35.1< / td > < td class = "benchmarkresult" > 39.5< / td > < td class = "benchmarkresult" > 99.9< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > BuildTypeNameSim 10/10< span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 25.8< / td > < td class = "benchmarkresult" > 22.2< / td > < td class = "benchmarkresult" > 25.7< / td > < td class = "benchmarkresult" > 37.3< / td > < td class = "benchmarkresult" > 69.9< / td > < / tr >
2026-01-21 11:59:17 +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 5 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'BuildTypeNameStr 0/0',data:[7.31,10.0,8.25,18.2,18.1]},
{name:'BuildTypeNameExp 0/0',data:[6.86,6.30,7.79,12.7,17.7]},
{name:'BuildTypeNameSim 0/0',data:[4.96,4.85,7.83,16.7,16.7]},
{name:'BuildTypeNameStr 10/10',data:[57.6,77.6,63.1,80.2,282]},
{name:'BuildTypeNameExp 10/10',data:[31.0,26.2,35.1,39.5,99.9]},
{name:'BuildTypeNameSim 10/10',data:[25.8,22.2,25.7,37.3,69.9]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs6" > < h4 > < a id = "bs54035654251116789780" href = "#bs54035654251116789780" > #< / a > Replace string by copy< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat with replace str< span class = "tooltiptext code" > std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
auto str_replace = [](std::string_view from, std::string_view pattern, std::string_view repl) {
std::string result;
for (size_t offset = 0; ;) {
size_t pos = from.find(pattern, offset);
if (pos == std::string::npos) {
result += from.substr(offset);
break;
}
result += from.substr(offset, pos - offset);
result += repl;
offset = pos + pattern.length();
}
return result;
};
return " < " + str_replace(from, pattern, repl) + " >" ;
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 205< / td > < td class = "benchmarkresult" > 238< / td > < td class = "benchmarkresult" > 308< / td > < td class = "benchmarkresult" > 347< / td > < td class = "benchmarkresult" > 475< / td > < / tr >
2026-01-21 11:59:17 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Concat with replace exp< span class = "tooltiptext code" > std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
return " < " + e_repl(from, pattern, repl) + " >" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr строковое выражение для замены подстрок
есть "из коробки".
2026-01-30 14:30:09 +00:00
simstr has a string expression for replacing substrings out of the box.< / span > < / span > < / td > < td class = "benchmarkresult" > 148< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 217< / td > < td class = "benchmarkresult" > 241< / td > < td class = "benchmarkresult" > 256< / td > < / tr >
2026-01-21 11:59:17 +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 6 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Concat with replace str',data:[205,238,308,347,475]},
{name:'Concat with replace exp',data:[148,132,217,241,256]}
2026-01-21 11:59:17 +00:00
]}< / script >
< div class = "benchset" id = "bs7" > < h4 > < a id = "bs77666948964429305550" href = "#bs77666948964429305550" > #< / a > Create Empty Str< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string e;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Empty lines, nothing unusual.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 2.56< / td > < td class = "benchmarkresult" > 2.16< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view e;< span class = "tooltiptext code" > template< typename T>
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 0.736< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 0.973< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa e;< span class = "tooltiptext code" > template< typename T>
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.365< / td > < td class = "benchmarkresult" > 0.182< / td > < td class = "benchmarkresult" > 0.360< / td > < td class = "benchmarkresult" > 1.81< / td > < td class = "benchmarkresult" > 0.942< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa e;< span class = "tooltiptext code" > template< typename T>
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.749< / td > < td class = "benchmarkresult" > 0.751< / td > < td class = "benchmarkresult" > 0.739< / td > < td class = "benchmarkresult" > 2.19< / td > < td class = "benchmarkresult" > 2.17< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> e;< span class = "tooltiptext code" > template< typename T>
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.22< / td > < td class = "benchmarkresult" > 1.16< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.55< / td > < td class = "benchmarkresult" > 2.22< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40> e;< span class = "tooltiptext code" > template< typename T>
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.58< / td > < td class = "benchmarkresult" > 2.57< / td > < / tr >
2026-01-21 11:59:17 +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 7 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string e;',data:[1.12,1.11,1.13,2.56,2.16]},
{name:'std::string_view e;',data:[0.368,0.736,0.364,1.83,0.973]},
{name:'ssa e;',data:[0.365,0.182,0.360,1.81,0.942]},
{name:'stringa e;',data:[0.749,0.751,0.739,2.19,2.17]},
{name:'lstringa< 20 > e;',data:[1.22,1.16,1.11,2.55,2.22]},
{name:'lstringa< 40 > e;',data:[1.12,1.11,1.11,2.58,2.57]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs8" > < h4 > < a id = "bs181001525395597238060" href = "#bs181001525395597238060" > #< / a > Create Str from short literal (9 symbols)< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
time is spent only copying 10 bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.86< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 1.86< / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 2.34< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
a pointer to text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.733< / td > < td class = "benchmarkresult" > 0.747< / td > < td class = "benchmarkresult" > 0.728< / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 1.25< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.374< / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.362< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 0.999< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
only a pointer to the text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 2.19< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
time is spent only on copying bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.86< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 2.60< / td > < td class = "benchmarkresult" > 2.67< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40> e = " Test text" ;< span class = "tooltiptext code" > template< typename T>
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.86< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.89< / td > < td class = "benchmarkresult" > 2.62< / td > < td class = "benchmarkresult" > 2.82< / td > < / tr >
2026-01-21 11:59:17 +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 8 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string e = "Test text";',data:[1.86,1.85,1.86,2.57,2.34]},
{name:'std::string_view e = "Test text";',data:[0.733,0.747,0.728,1.85,1.25]},
{name:'ssa e = "Test text";',data:[0.374,0.738,0.362,1.82,0.999]},
{name:'stringa e = "Test text";',data:[1.10,1.10,1.11,2.57,2.19]},
{name:'lstringa< 20 > e = "Test text";',data:[1.86,1.84,1.83,2.60,2.67]},
{name:'lstringa< 40 > e = "Test text";',data:[1.86,1.83,1.89,2.62,2.82]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs9" > < h4 > < a id = "bs132333183298742730280" href = "#bs132333183298742730280" > #< / a > Create Str from long literal (30 symbols)< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...< / span > < / span > < / td > < td class = "benchmarkresult" > 18.7< / td > < td class = "benchmarkresult" > 18.9< / td > < td class = "benchmarkresult" > 71.2< / td > < td class = "benchmarkresult" > 75.9< / td > < td class = "benchmarkresult" > 16.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
remember the pointer to the text and its size.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.743< / td > < td class = "benchmarkresult" > 0.733< / td > < td class = "benchmarkresult" > 0.722< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.27< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.378< / td > < td class = "benchmarkresult" > 0.733< / td > < td class = "benchmarkresult" > 0.363< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 0.995< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
stringa doesn't lag behind on constant literals!< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.16< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 2.22< / td > < td class = "benchmarkresult" > 2.24< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Obviously, 30 characters already require allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 20.6< / td > < td class = "benchmarkresult" > 20.7< / td > < td class = "benchmarkresult" > 72.4< / td > < td class = "benchmarkresult" > 75.6< / td > < td class = "benchmarkresult" > 16.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40> e = " 123456789012345678901234567890" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
bytes are simply copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 1.88< / td > < td class = "benchmarkresult" > 2.53< / td > < td class = "benchmarkresult" > 3.30< / td > < td class = "benchmarkresult" > 2.96< / td > < / tr >
2026-01-21 11:59:17 +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 9 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string e = "123456789012345678901234567890";',data:[18.7,18.9,71.2,75.9,16.2]},
{name:'std::string_view e = "123456789012345678901234567890";',data:[0.743,0.733,0.722,1.83,1.27]},
{name:'ssa e = "123456789012345678901234567890";',data:[0.378,0.733,0.363,1.84,0.995]},
{name:'stringa e = "123456789012345678901234567890";',data:[1.12,1.16,1.09,2.22,2.24]},
{name:'lstringa< 20 > e = "123456789012345678901234567890";',data:[20.6,20.7,72.4,75.6,16.5]},
{name:'lstringa< 40 > e = "123456789012345678901234567890";',data:[2.57,1.88,2.53,3.30,2.96]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs10" > < h4 > < a id = "bs6234433963744178700" href = "#bs6234433963744178700" > #< / a > Create copy of Str with 9 symbols< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
The string is within the SSO, so it just copies the bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.91< / td > < td class = "benchmarkresult" > 6.00< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 5.11< / td > < td class = "benchmarkresult" > 2.22< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 0.378< / td > < td class = "benchmarkresult" > 0.363< / td > < td class = "benchmarkresult" > 3.80< / td > < td class = "benchmarkresult" > 1.23< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
string information is copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.376< / td > < td class = "benchmarkresult" > 0.393< / td > < td class = "benchmarkresult" > 0.367< / td > < td class = "benchmarkresult" > 3.80< / td > < td class = "benchmarkresult" > 1.23< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
especially if it is initialized with a literal.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.16< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.28< / td > < td class = "benchmarkresult" > 4.02< / td > < td class = "benchmarkresult" > 2.55< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
In both cases, the internal buffer is sufficient.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.54< / td > < td class = "benchmarkresult" > 4.47< / td > < td class = "benchmarkresult" > 5.19< / td > < td class = "benchmarkresult" > 7.74< / td > < td class = "benchmarkresult" > 15.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40> e = " Test text" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Only bytes are copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.54< / td > < td class = "benchmarkresult" > 5.16< / td > < td class = "benchmarkresult" > 4.84< / td > < td class = "benchmarkresult" > 8.20< / td > < td class = "benchmarkresult" > 14.6< / td > < / tr >
2026-01-21 11:59:17 +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 0 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string e = "Test text"; auto c{e};',data:[4.91,6.00,1.84,5.11,2.22]},
{name:'std::string_view e = "Test text"; auto c{e};',data:[0.368,0.378,0.363,3.80,1.23]},
{name:'ssa e = "Test text"; auto c{e};',data:[0.376,0.393,0.367,3.80,1.23]},
{name:'stringa e = "Test text"; auto c{e};',data:[1.16,1.10,1.28,4.02,2.55]},
{name:'lstringa< 20 > e = "Test text"; auto c{e};',data:[4.54,4.47,5.19,7.74,15.3]},
{name:'lstringa< 40 > e = "Test text"; auto c{e};',data:[4.54,5.16,4.84,8.20,14.6]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs11" > < h4 > < a id = "bs76384575499199461500" href = "#bs76384575499199461500" > #< / a > Create copy of Str with 30 symbols< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
SSO is no longer sufficient. And again, how allocation lags under Windows...< / span > < / span > < / td > < td class = "benchmarkresult" > 19.3< / td > < td class = "benchmarkresult" > 24.1< / td > < td class = "benchmarkresult" > 75.0< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 35.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.740< / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.726< / td > < td class = "benchmarkresult" > 1.50< / td > < td class = "benchmarkresult" > 1.24< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 0.734< / td > < td class = "benchmarkresult" > 0.362< / td > < td class = "benchmarkresult" > 1.48< / td > < td class = "benchmarkresult" > 1.02< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
compare with the previous benchmark.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.98< / td > < td class = "benchmarkresult" > 2.21< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Doesn't fit, allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 19.7< / td > < td class = "benchmarkresult" > 19.9< / td > < td class = "benchmarkresult" > 75.5< / td > < td class = "benchmarkresult" > 78.3< / td > < td class = "benchmarkresult" > 16.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40> e = " 123456789012345678901234567890" ; auto c{e};< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Placed in the internal buffer.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.53< / td > < td class = "benchmarkresult" > 4.47< / td > < td class = "benchmarkresult" > 4.47< / td > < td class = "benchmarkresult" > 7.08< / td > < td class = "benchmarkresult" > 14.3< / td > < / tr >
2026-01-21 11:59:17 +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 1 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string e = "123456789012345678901234567890"; auto c{e};',data:[19.3,24.1,75.0,77.2,35.5]},
{name:'std::string_view e = "123456789012345678901234567890"; auto c{e};',data:[0.740,0.738,0.726,1.50,1.24]},
{name:'ssa e = "123456789012345678901234567890"; auto c{e};',data:[0.368,0.734,0.362,1.48,1.02]},
{name:'stringa e = "123456789012345678901234567890"; auto c{e};',data:[1.10,1.10,1.84,2.98,2.21]},
{name:'lstringa< 20 > e = "123456789012345678901234567890"; auto c{e};',data:[19.7,19.9,75.5,78.3,16.3]},
{name:'lstringa< 40 > e = "123456789012345678901234567890"; auto c{e};',data:[4.53,4.47,4.47,7.08,14.3]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs12" > < h4 > < a id = "bs21623892135774528620" href = "#bs21623892135774528620" > #< / a > Find 9 symbols text in end of 99 symbols text< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
However, Windows and Linux are clearly in different weight classes.< / span > < / span > < / td > < td class = "benchmarkresult" > 7.37< / td > < td class = "benchmarkresult" > 7.05< / td > < td class = "benchmarkresult" > 39.2< / td > < td class = "benchmarkresult" > 40.8< / td > < td class = "benchmarkresult" > 45.7< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.46< / td > < td class = "benchmarkresult" > 7.46< / td > < td class = "benchmarkresult" > 39.4< / td > < td class = "benchmarkresult" > 39.9< / td > < td class = "benchmarkresult" > 53.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.65< / td > < td class = "benchmarkresult" > 6.38< / td > < td class = "benchmarkresult" > 17.7< / td > < td class = "benchmarkresult" > 22.2< / td > < td class = "benchmarkresult" > 51.0< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.64< / td > < td class = "benchmarkresult" > 6.78< / td > < td class = "benchmarkresult" > 18.0< / td > < td class = "benchmarkresult" > 29.7< / td > < td class = "benchmarkresult" > 51.7< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20>::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.93< / td > < td class = "benchmarkresult" > 6.83< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 21.8< / td > < td class = "benchmarkresult" > 44.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 40>::find;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.81< / td > < td class = "benchmarkresult" > 7.36< / td > < td class = "benchmarkresult" > 17.6< / td > < td class = "benchmarkresult" > 21.1< / td > < td class = "benchmarkresult" > 44.2< / td > < / tr >
2026-01-21 11:59:17 +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 2 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string::find;',data:[7.37,7.05,39.2,40.8,45.7]},
{name:'std::string_view::find;',data:[7.46,7.46,39.4,39.9,53.5]},
{name:'ssa::find;',data:[7.65,6.38,17.7,22.2,51.0]},
{name:'stringa::find;',data:[7.64,6.78,18.0,29.7,51.7]},
{name:'lstringa< 20 > ::find;',data:[6.93,6.83,18.6,21.8,44.5]},
{name:'lstringa< 40 > ::find;',data:[6.81,7.36,17.6,21.1,44.2]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs13" > < h4 > < a id = "bs170792414351801782640" href = "#bs170792414351801782640" > #< / a > Copy not literal Str with N symbols< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/15< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.93< / td > < td class = "benchmarkresult" > 5.93< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 4.40< / td > < td class = "benchmarkresult" > 36.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/16< span class = "tooltiptext code" > template< typename T>
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-01-21 11:59:17 +00:00
SSO у std::string меньше, насколько я помню, 11 символов + 0.
The jump where SSO ends and allocation begins is clearly visible.
Note that WASM is 32-bit, and the size of the SSO for std::string is
2026-01-30 14:30:09 +00:00
smaller, as far as I remember: 11 characters + 0.< / span > < / span > < / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 24.7< / td > < td class = "benchmarkresult" > 77.0< / td > < td class = "benchmarkresult" > 80.2< / td > < td class = "benchmarkresult" > 36.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/23< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Then the time for copying bytes is simply added.< / span > < / span > < / td > < td class = "benchmarkresult" > 24.9< / td > < td class = "benchmarkresult" > 25.4< / td > < td class = "benchmarkresult" > 76.6< / td > < td class = "benchmarkresult" > 81.4< / td > < td class = "benchmarkresult" > 35.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/24< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.6< / td > < td class = "benchmarkresult" > 24.0< / td > < td class = "benchmarkresult" > 78.5< / td > < td class = "benchmarkresult" > 79.7< / td > < td class = "benchmarkresult" > 36.4< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/32< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.7< / td > < td class = "benchmarkresult" > 23.7< / td > < td class = "benchmarkresult" > 83.9< / td > < td class = "benchmarkresult" > 86.8< / td > < td class = "benchmarkresult" > 40.9< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/64< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.7< / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 80.9< / td > < td class = "benchmarkresult" > 84.2< / td > < td class = "benchmarkresult" > 40.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/128< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 25.3< / td > < td class = "benchmarkresult" > 87.4< / td > < td class = "benchmarkresult" > 86.2< / td > < td class = "benchmarkresult" > 42.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/256< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 84.4< / td > < td class = "benchmarkresult" > 88.1< / td > < td class = "benchmarkresult" > 62.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/512< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.4< / td > < td class = "benchmarkresult" > 30.1< / td > < td class = "benchmarkresult" > 86.3< / td > < td class = "benchmarkresult" > 91.5< / td > < td class = "benchmarkresult" > 62.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/1024< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 39.9< / td > < td class = "benchmarkresult" > 39.5< / td > < td class = "benchmarkresult" > 94.3< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 66.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/2048< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 116< / td > < td class = "benchmarkresult" > 114< / td > < td class = "benchmarkresult" > 131< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 99.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string copy{str_with_len_N};/4096< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
The longer the string, the longer it takes to create a copy.< / span > < / span > < / td > < td class = "benchmarkresult" > 151< / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 192< / td > < td class = "benchmarkresult" > 179< / td > < td class = "benchmarkresult" > 153< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/15< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
meaning it must store characters itself.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.29< / td > < td class = "benchmarkresult" > 4.01< / td > < td class = "benchmarkresult" > 2.55< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/16< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
increment was replaced with a regular one, judging by the time.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.28< / td > < td class = "benchmarkresult" > 4.07< / td > < td class = "benchmarkresult" > 4.83< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/23< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
copies faster than 15 in std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.27< / td > < td class = "benchmarkresult" > 4.01< / td > < td class = "benchmarkresult" > 4.84< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/24< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Time is added for the atomic counter increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.97< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/32< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 4.92< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/64< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 4.85< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/128< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 4.84< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/256< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.89< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/512< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 15.7< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 4.84< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/1024< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.89< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/2048< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 17.9< / td > < td class = "benchmarkresult" > 15.7< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.88< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa copy{str_with_len_N};/4096< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
increment; copying time does not depend on the string length.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 17.8< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 4.93< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/15< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
WASM has a 32-bit architecture, so SSO is up to 19 characters.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.63< / td > < td class = "benchmarkresult" > 4.44< / td > < td class = "benchmarkresult" > 4.42< / td > < td class = "benchmarkresult" > 7.45< / td > < td class = "benchmarkresult" > 14.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/16< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.59< / td > < td class = "benchmarkresult" > 4.48< / td > < td class = "benchmarkresult" > 4.48< / td > < td class = "benchmarkresult" > 7.54< / td > < td class = "benchmarkresult" > 14.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/23< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.55< / td > < td class = "benchmarkresult" > 4.78< / td > < td class = "benchmarkresult" > 5.05< / td > < td class = "benchmarkresult" > 7.45< / td > < td class = "benchmarkresult" > 29.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/24< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
And then it starts to behave like std::string when copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 24.6< / td > < td class = "benchmarkresult" > 24.8< / td > < td class = "benchmarkresult" > 74.9< / td > < td class = "benchmarkresult" > 78.1< / td > < td class = "benchmarkresult" > 30.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/32< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.6< / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 83.3< / td > < td class = "benchmarkresult" > 89.5< / td > < td class = "benchmarkresult" > 32.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/64< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 77.8< / td > < td class = "benchmarkresult" > 82.6< / td > < td class = "benchmarkresult" > 32.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/128< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 26.3< / td > < td class = "benchmarkresult" > 26.4< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 84.5< / td > < td class = "benchmarkresult" > 37.0< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/256< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27.0< / td > < td class = "benchmarkresult" > 27.4< / td > < td class = "benchmarkresult" > 82.5< / td > < td class = "benchmarkresult" > 86.8< / td > < td class = "benchmarkresult" > 55.7< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/512< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.9< / td > < td class = "benchmarkresult" > 29.9< / td > < td class = "benchmarkresult" > 85.9< / td > < td class = "benchmarkresult" > 89.9< / td > < td class = "benchmarkresult" > 55.7< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/1024< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 89.6< / td > < td class = "benchmarkresult" > 93.1< / td > < td class = "benchmarkresult" > 98.4< / td > < td class = "benchmarkresult" > 97.1< / td > < td class = "benchmarkresult" > 61.8< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/2048< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 113< / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 92.0< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> copy{str_with_len_N};/4096< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 186< / td > < td class = "benchmarkresult" > 142< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/15< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.16< / td > < td class = "benchmarkresult" > 4.54< / td > < td class = "benchmarkresult" > 5.16< / td > < td class = "benchmarkresult" > 8.77< / td > < td class = "benchmarkresult" > 14.4< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/16< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.84< / td > < td class = "benchmarkresult" > 4.50< / td > < td class = "benchmarkresult" > 5.22< / td > < td class = "benchmarkresult" > 8.49< / td > < td class = "benchmarkresult" > 14.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/23< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.95< / td > < td class = "benchmarkresult" > 4.58< / td > < td class = "benchmarkresult" > 4.84< / td > < td class = "benchmarkresult" > 8.36< / td > < td class = "benchmarkresult" > 15.3< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/24< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.87< / td > < td class = "benchmarkresult" > 4.49< / td > < td class = "benchmarkresult" > 4.82< / td > < td class = "benchmarkresult" > 8.48< / td > < td class = "benchmarkresult" > 14.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/32< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.49< / td > < td class = "benchmarkresult" > 4.09< / td > < td class = "benchmarkresult" > 7.79< / td > < td class = "benchmarkresult" > 11.4< / td > < td class = "benchmarkresult" > 18.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/64< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.10< / td > < td class = "benchmarkresult" > 5.62< / td > < td class = "benchmarkresult" > 7.74< / td > < td class = "benchmarkresult" > 11.5< / td > < td class = "benchmarkresult" > 17.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/128< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.43< / td > < td class = "benchmarkresult" > 7.65< / td > < td class = "benchmarkresult" > 8.17< / td > < td class = "benchmarkresult" > 12.2< / td > < td class = "benchmarkresult" > 18.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/256< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.93< / td > < td class = "benchmarkresult" > 7.91< / td > < td class = "benchmarkresult" > 9.12< / td > < td class = "benchmarkresult" > 13.0< / td > < td class = "benchmarkresult" > 19.8< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/512< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
allocation or atomic increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 19.9< / td > < td class = "benchmarkresult" > 23.0< / td > < td class = "benchmarkresult" > 10.8< / td > < td class = "benchmarkresult" > 14.3< / td > < td class = "benchmarkresult" > 22.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/1024< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
And then it's like everyone else.< / span > < / span > < / td > < td class = "benchmarkresult" > 93.2< / td > < td class = "benchmarkresult" > 92.2< / td > < td class = "benchmarkresult" > 100< / td > < td class = "benchmarkresult" > 99.0< / td > < td class = "benchmarkresult" > 62.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/2048< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 117< / td > < td class = "benchmarkresult" > 110< / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 131< / td > < td class = "benchmarkresult" > 92.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> copy{str_with_len_N};/4096< span class = "tooltiptext code" > template< typename T>
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-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 187< / td > < td class = "benchmarkresult" > 191< / td > < td class = "benchmarkresult" > 147< / td > < / tr >
2026-01-21 11:59:17 +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 3 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string copy{str_with_len_N};/15',data:[4.93,5.93,1.83,4.40,36.2]},
{name:'std::string copy{str_with_len_N};/16',data:[24.2,24.7,77.0,80.2,36.3]},
{name:'std::string copy{str_with_len_N};/23',data:[24.9,25.4,76.6,81.4,35.6]},
{name:'std::string copy{str_with_len_N};/24',data:[22.6,24.0,78.5,79.7,36.4]},
{name:'std::string copy{str_with_len_N};/32',data:[22.7,23.7,83.9,86.8,40.9]},
{name:'std::string copy{str_with_len_N};/64',data:[22.7,23.9,80.9,84.2,40.6]},
{name:'std::string copy{str_with_len_N};/128',data:[23.9,25.3,87.4,86.2,42.3]},
{name:'std::string copy{str_with_len_N};/256',data:[23.9,25.6,84.4,88.1,62.6]},
{name:'std::string copy{str_with_len_N};/512',data:[28.4,30.1,86.3,91.5,62.1]},
{name:'std::string copy{str_with_len_N};/1024',data:[39.9,39.5,94.3,101,66.3]},
{name:'std::string copy{str_with_len_N};/2048',data:[116,114,131,129,99.3]},
{name:'std::string copy{str_with_len_N};/4096',data:[151,153,192,179,153]},
{name:'stringa copy{str_with_len_N};/15',data:[1.11,1.12,1.29,4.01,2.55]},
{name:'stringa copy{str_with_len_N};/16',data:[1.10,1.09,1.28,4.07,4.83]},
{name:'stringa copy{str_with_len_N};/23',data:[1.13,1.10,1.27,4.01,4.84]},
{name:'stringa copy{str_with_len_N};/24',data:[16.4,16.2,16.3,18.3,4.97]},
{name:'stringa copy{str_with_len_N};/32',data:[16.3,16.0,15.9,18.6,4.92]},
{name:'stringa copy{str_with_len_N};/64',data:[16.3,16.3,16.0,18.5,4.85]},
{name:'stringa copy{str_with_len_N};/128',data:[16.4,16.1,15.8,18.6,4.84]},
{name:'stringa copy{str_with_len_N};/256',data:[16.1,16.3,15.8,18.3,4.89]},
{name:'stringa copy{str_with_len_N};/512',data:[16.1,16.2,15.7,18.5,4.84]},
{name:'stringa copy{str_with_len_N};/1024',data:[16.1,16.1,15.8,18.3,4.89]},
{name:'stringa copy{str_with_len_N};/2048',data:[16.1,17.9,15.7,18.3,4.88]},
{name:'stringa copy{str_with_len_N};/4096',data:[16.0,17.8,15.8,18.5,4.93]},
{name:'lstringa< 16 > copy{str_with_len_N};/15',data:[4.63,4.44,4.42,7.45,14.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/16',data:[4.59,4.48,4.48,7.54,14.2]},
{name:'lstringa< 16 > copy{str_with_len_N};/23',data:[4.55,4.78,5.05,7.45,29.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/24',data:[24.6,24.8,74.9,78.1,30.1]},
{name:'lstringa< 16 > copy{str_with_len_N};/32',data:[23.6,23.9,83.3,89.5,32.1]},
{name:'lstringa< 16 > copy{str_with_len_N};/64',data:[25.6,25.6,77.8,82.6,32.6]},
{name:'lstringa< 16 > copy{str_with_len_N};/128',data:[26.3,26.4,83.5,84.5,37.0]},
{name:'lstringa< 16 > copy{str_with_len_N};/256',data:[27.0,27.4,82.5,86.8,55.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/512',data:[28.9,29.9,85.9,89.9,55.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/1024',data:[89.6,93.1,98.4,97.1,61.8]},
{name:'lstringa< 16 > copy{str_with_len_N};/2048',data:[113,107,127,128,92.0]},
{name:'lstringa< 16 > copy{str_with_len_N};/4096',data:[127,128,181,186,142]},
{name:'lstringa< 512 > copy{str_with_len_N};/15',data:[5.16,4.54,5.16,8.77,14.4]},
{name:'lstringa< 512 > copy{str_with_len_N};/16',data:[4.84,4.50,5.22,8.49,14.5]},
{name:'lstringa< 512 > copy{str_with_len_N};/23',data:[4.95,4.58,4.84,8.36,15.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/24',data:[4.87,4.49,4.82,8.48,14.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/32',data:[4.49,4.09,7.79,11.4,18.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/64',data:[6.10,5.62,7.74,11.5,17.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/128',data:[6.43,7.65,8.17,12.2,18.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/256',data:[7.93,7.91,9.12,13.0,19.8]},
{name:'lstringa< 512 > copy{str_with_len_N};/512',data:[19.9,23.0,10.8,14.3,22.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/1024',data:[93.2,92.2,100,99.0,62.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/2048',data:[117,110,128,131,92.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/4096',data:[128,123,187,191,147]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs14" > < h4 > < a id = "bs94756718925776995960" href = "#bs94756718925776995960" > #< / a > Convert to int ' 1234567' < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 10);< span class = "tooltiptext code" > void ToIntStr10(benchmark::State& state, const std::string& s, int c) {
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-01-30 14:30:09 +00:00
Here, I attempted to run tests that are similar in logic to std::from_chars.< / span > < / span > < / td > < td class = "benchmarkresult" > 26.9< / td > < td class = "benchmarkresult" > 27.0< / td > < td class = "benchmarkresult" > 31.0< / td > < td class = "benchmarkresult" > 52.0< / td > < td class = "benchmarkresult" > 71.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view s = " 123456789" ; std::from_chars(s.data(), s.data() + s.size(), res, 10);< span class = "tooltiptext code" > void ToIntFromChars10(benchmark::State& state, const std::string_view& s, int c) {
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-01-30 14:30:09 +00:00
signs, spaces, 0x prefixes, etc.< / span > < / span > < / td > < td class = "benchmarkresult" > 14.8< / td > < td class = "benchmarkresult" > 12.2< / td > < td class = "benchmarkresult" > 14.0< / td > < td class = "benchmarkresult" > 13.8< / td > < td class = "benchmarkresult" > 27.4< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
decimal system, no leading spaces, and no plus sign.< / span > < / span > < / td > < td class = "benchmarkresult" > 12.8< / td > < td class = "benchmarkresult" > 9.52< / td > < td class = "benchmarkresult" > 14.1< / td > < td class = "benchmarkresult" > 15.4< / td > < td class = "benchmarkresult" > 19.1< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.3< / td > < td class = "benchmarkresult" > 7.82< / td > < td class = "benchmarkresult" > 13.4< / td > < td class = "benchmarkresult" > 15.3< / td > < td class = "benchmarkresult" > 17.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> s = " 123456789" ; int res = s.to_int< int, true, 10, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 13.3< / td > < td class = "benchmarkresult" > 8.20< / td > < td class = "benchmarkresult" > 14.1< / td > < td class = "benchmarkresult" > 14.7< / td > < td class = "benchmarkresult" > 17.2< / td > < / tr >
2026-01-21 11:59:17 +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 4 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);',data:[26.9,27.0,31.0,52.0,71.1]},
{name:'std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);',data:[14.8,12.2,14.0,13.8,27.4]},
{name:'stringa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[12.8,9.52,14.1,15.4,19.1]},
{name:'ssa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[12.3,7.82,13.4,15.3,17.2]},
{name:'lstringa< 20 > s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[13.3,8.20,14.1,14.7,17.2]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs15" > < h4 > < a id = "bs182426078870126042750" href = "#bs182426078870126042750" > #< / a > Convert to unsigned ' abcDef' < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string s = " abcDef" ; int res = std::strtol(s.c_str(), 0, 16);< span class = "tooltiptext code" > void ToIntStr16(benchmark::State& state, const std::string& s, int c) {
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-01-30 14:30:09 +00:00
Everything is the same, only for the hexadecimal system< / span > < / span > < / td > < td class = "benchmarkresult" > 23.5< / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 34.0< / td > < td class = "benchmarkresult" > 35.4< / td > < td class = "benchmarkresult" > 54.9< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view s = " abcDef" ; std::from_chars(s.data(), s.data() + s.size(), res, 16);< span class = "tooltiptext code" > void ToIntFromChars16(benchmark::State& state, const std::string_view& s, int c) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.74< / td > < td class = "benchmarkresult" > 9.61< / td > < td class = "benchmarkresult" > 8.09< / td > < td class = "benchmarkresult" > 12.3< / td > < td class = "benchmarkresult" > 28.6< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.7< / td > < td class = "benchmarkresult" > 8.48< / td > < td class = "benchmarkresult" > 12.4< / td > < td class = "benchmarkresult" > 14.1< / td > < td class = "benchmarkresult" > 17.5< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 7.78< / td > < td class = "benchmarkresult" > 12.1< / td > < td class = "benchmarkresult" > 13.9< / td > < td class = "benchmarkresult" > 17.2< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 20> s = " abcDef" ; int res = s.to_int< int, true, 16, false>< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.4< / td > < td class = "benchmarkresult" > 8.37< / td > < td class = "benchmarkresult" > 12.2< / td > < td class = "benchmarkresult" > 14.2< / td > < td class = "benchmarkresult" > 16.1< / td > < / tr >
2026-01-21 11:59:17 +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 5 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);',data:[23.5,24.2,34.0,35.4,54.9]},
{name:'std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);',data:[9.74,9.61,8.09,12.3,28.6]},
{name:'stringa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[12.7,8.48,12.4,14.1,17.5]},
{name:'ssa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[12.5,7.78,12.1,13.9,17.2]},
{name:'lstringa< 20 > s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[12.4,8.37,12.2,14.2,16.1]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs16" > < h4 > < a id = "bs52606100125109966680" href = "#bs52606100125109966680" > #< / a > Convert to int ' 1234567' < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 0);< span class = "tooltiptext code" > void ToIntStr0(benchmark::State& state, const std::string& s, int c) {
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-01-30 14:30:09 +00:00
And here we have parsing of an arbitrary number.< / span > < / span > < / td > < td class = "benchmarkresult" > 28.1< / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 43.2< / td > < td class = "benchmarkresult" > 45.3< / td > < td class = "benchmarkresult" > 77.8< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa s = " 123456789" ; int res = s.to_int< int>; // Check overflow< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 18.5< / td > < td class = "benchmarkresult" > 15.0< / td > < td class = "benchmarkresult" > 18.6< / td > < td class = "benchmarkresult" > 19.2< / td > < td class = "benchmarkresult" > 24.0< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa s = " 123456789" ; int res = s.to_int< int, false>; // No check overflow< span class = "tooltiptext code" > void ToIntNoOverflow(benchmark::State& state, ssa t, int c) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15.7< / td > < td class = "benchmarkresult" > 10.7< / td > < td class = "benchmarkresult" > 15.6< / td > < td class = "benchmarkresult" > 16.8< / td > < td class = "benchmarkresult" > 22.7< / td > < / tr >
2026-01-21 11:59:17 +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-01-30 14:30:09 +00:00
{name:'std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);',data:[28.1,28.5,43.2,45.3,77.8]},
{name:'stringa s = " 123456789"; int res = s.to_int< int > ; // Check overflow',data:[18.5,15.0,18.6,19.2,24.0]},
{name:'ssa s = " 123456789"; int res = s.to_int< int , false > ; // No check overflow',data:[15.7,10.7,15.6,16.8,22.7]}
2025-11-26 19:15:50 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs17" > < h4 > < a id = "bs182348477702821075660" href = "#bs182348477702821075660" > #< / a > Convert to double ' 1234.567e10' < / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-11-26 19:15:50 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string s = " 1234.567e10" ; double res = std::strtod(s.c_str(), nullptr);< span class = "tooltiptext code" > void ToDoubleStr(benchmark::State& state, const std::string& s, double c) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 67.6< / td > < td class = "benchmarkresult" > 66.5< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 207< / td > < / tr >
2025-11-26 19:15:50 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string_view s = " 1234.567e10" ; std::from_chars(s.data(), s.data() + s.size(), res);< span class = "tooltiptext code" > void ToDoubleFromChars(benchmark::State& state, const std::string_view& s, double c) {
for (auto _: state) {
double res = 0;
if (std::from_chars(s.data(), s.data() + s.size(), res).ec != std::errc{}) {
state.SkipWithError(" not equal" );
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.6< / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 60.4< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 107< / td > < / tr >
2025-11-26 19:15:50 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa s = " 1234.567e10" ; double res = *s.to_double()< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 27.5< / td > < td class = "benchmarkresult" > 25.1< / td > < td class = "benchmarkresult" > 34.9< / td > < td class = "benchmarkresult" > 36.6< / td > < td class = "benchmarkresult" > 42.2< / td > < / tr >
2026-01-21 11:59:17 +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 7 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);',data:[67.6,66.5,101,102,207]},
{name:'std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);',data:[24.6,25.6,60.4,77.2,107]},
{name:'ssa s = "1234.567e10"; double res = *s.to_double()',data:[27.5,25.1,34.9,36.6,42.2]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs18" > < h4 > < a id = "bs96505608161678391610" href = "#bs96505608161678391610" > #< / a > Append const literal of 16 bytes 64 times, 1024 total length< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::stringstream str; ... str < < " abbaabbaabbaabba" ;< span class = "tooltiptext code" > void AppendStreamConstLiteral(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1347< / td > < td class = "benchmarkresult" > 1342< / td > < td class = "benchmarkresult" > 4911< / td > < td class = "benchmarkresult" > 5946< / td > < td class = "benchmarkresult" > 4462< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str; ... str += " abbaabbaabbaabba" ;< span class = "tooltiptext code" > void AppendStdStringConstLiteral(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 386< / td > < td class = "benchmarkresult" > 384< / td > < td class = "benchmarkresult" > 1071< / td > < td class = "benchmarkresult" > 1228< / td > < td class = "benchmarkresult" > 629< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 8> str; ... str += " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 371< / td > < td class = "benchmarkresult" > 369< / td > < td class = "benchmarkresult" > 734< / td > < td class = "benchmarkresult" > 927< / td > < td class = "benchmarkresult" > 780< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 128> str; ... str += " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
required, and the faster the result.< / span > < / span > < / td > < td class = "benchmarkresult" > 278< / td > < td class = "benchmarkresult" > 275< / td > < td class = "benchmarkresult" > 406< / td > < td class = "benchmarkresult" > 562< / td > < td class = "benchmarkresult" > 625< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> str; ... str += " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 253< / td > < td class = "benchmarkresult" > 215< / td > < td class = "benchmarkresult" > 229< / td > < td class = "benchmarkresult" > 357< / td > < td class = "benchmarkresult" > 499< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 1024> str; ... str += " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 155< / td > < td class = "benchmarkresult" > 140< / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 244< / td > < td class = "benchmarkresult" > 395< / td > < / tr >
2026-01-21 11:59:17 +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 1 8 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::stringstream str; ... str < < "abbaabbaabbaabba";',data:[1347,1342,4911,5946,4462]},
{name:'std::string str; ... str += "abbaabbaabbaabba";',data:[386,384,1071,1228,629]},
{name:'lstringa< 8 > str; ... str += "abbaabbaabbaabba";',data:[371,369,734,927,780]},
{name:'lstringa< 128 > str; ... str += "abbaabbaabbaabba";',data:[278,275,406,562,625]},
{name:'lstringa< 512 > str; ... str += "abbaabbaabbaabba";',data:[253,215,229,357,499]},
{name:'lstringa< 1024 > str; ... str += "abbaabbaabbaabba";',data:[155,140,153,244,395]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs19" > < h4 > < a id = "bs36931044816721597850" href = "#bs36931044816721597850" > #< / a > Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ;< span class = "tooltiptext code" > void AppendStreamStrConstLiteral(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1360< / td > < td class = "benchmarkresult" > 1366< / td > < td class = "benchmarkresult" > 4649< / td > < td class = "benchmarkresult" > 5660< / td > < td class = "benchmarkresult" > 4589< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str; ... str += str_var + " abbaabbaabbaabba" ;< span class = "tooltiptext code" > void AppendStdStrStrConstLiteral(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1256< / td > < td class = "benchmarkresult" > 1302< / td > < td class = "benchmarkresult" > 3931< / td > < td class = "benchmarkresult" > 3839< / td > < td class = "benchmarkresult" > 1962< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 458< / td > < td class = "benchmarkresult" > 445< / td > < td class = "benchmarkresult" > 745< / td > < td class = "benchmarkresult" > 808< / td > < td class = "benchmarkresult" > 905< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 335< / td > < td class = "benchmarkresult" > 372< / td > < td class = "benchmarkresult" > 453< / td > < td class = "benchmarkresult" > 531< / td > < td class = "benchmarkresult" > 768< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 333< / td > < td class = "benchmarkresult" > 325< / td > < td class = "benchmarkresult" > 298< / td > < td class = "benchmarkresult" > 400< / td > < td class = "benchmarkresult" > 648< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 236< / td > < td class = "benchmarkresult" > 244< / td > < td class = "benchmarkresult" > 208< / td > < td class = "benchmarkresult" > 272< / td > < td class = "benchmarkresult" > 533< / td > < / tr >
2026-01-21 11:59:17 +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 1 9 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; ' , data: [ 1360 , 1366 , 4649 , 5660 , 4589 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba";',data:[1256,1302,3931,3839,1962]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba";',data:[458,445,745,808,905]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba";',data:[335,372,453,531,768]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba";',data:[333,325,298,400,648]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba";',data:[236,244,208,272,533]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs20" > < h4 > < a id = "bs8293767858383349360" href = "#bs8293767858383349360" > #< / a > Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > void AppendStreamStrConstLiteralBig(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 76814< / td > < td class = "benchmarkresult" > 72361< / td > < td class = "benchmarkresult" > 222544< / td > < td class = "benchmarkresult" > 280515< / td > < td class = "benchmarkresult" > 225107< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > void AppendStdStrStrConstLiteralBig(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 81104< / td > < td class = "benchmarkresult" > 75918< / td > < td class = "benchmarkresult" > 200929< / td > < td class = "benchmarkresult" > 192412< / td > < td class = "benchmarkresult" > 105312< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 35576< / td > < td class = "benchmarkresult" > 30423< / td > < td class = "benchmarkresult" > 19728< / td > < td class = "benchmarkresult" > 24325< / td > < td class = "benchmarkresult" > 43046< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 18020< / td > < td class = "benchmarkresult" > 18518< / td > < td class = "benchmarkresult" > 16771< / td > < td class = "benchmarkresult" > 21822< / td > < td class = "benchmarkresult" > 39544< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15532< / td > < td class = "benchmarkresult" > 17088< / td > < td class = "benchmarkresult" > 16447< / td > < td class = "benchmarkresult" > 22706< / td > < td class = "benchmarkresult" > 38237< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16198< / td > < td class = "benchmarkresult" > 17198< / td > < td class = "benchmarkresult" > 16187< / td > < td class = "benchmarkresult" > 22733< / td > < td class = "benchmarkresult" > 38420< / td > < / tr >
2026-01-21 11:59:17 +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 0 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; 2048 times ' , data: [ 76814 , 72361 , 222544 , 280515 , 225107 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[81104,75918,200929,192412,105312]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[35576,30423,19728,24325,43046]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[18020,18518,16771,21822,39544]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[15532,17088,16447,22706,38237]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[16198,17198,16187,22733,38420]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs21" > < h4 > < a id = "bs66949588770596833730" href = "#bs66949588770596833730" > #< / a > Append 2 string of 16 bytes 32 times, 1024 total length< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::stringstream str; ... str < < str_var1 < < str_var2;< span class = "tooltiptext code" > void AppendStream2String(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1362< / td > < td class = "benchmarkresult" > 1367< / td > < td class = "benchmarkresult" > 4484< / td > < td class = "benchmarkresult" > 5409< / td > < td class = "benchmarkresult" > 4614< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str; ... str += str_var1 + str_var2;< span class = "tooltiptext code" > void AppendStdStr2String(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1379< / td > < td class = "benchmarkresult" > 1440< / td > < td class = "benchmarkresult" > 4039< / td > < td class = "benchmarkresult" > 3876< / td > < td class = "benchmarkresult" > 2454< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 16> str; ... str += str_var1 + str_var2;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 563< / td > < td class = "benchmarkresult" > 539< / td > < td class = "benchmarkresult" > 837< / td > < td class = "benchmarkresult" > 901< / td > < td class = "benchmarkresult" > 1218< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 128> str; ... str += str_var1 + str_var2;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 483< / td > < td class = "benchmarkresult" > 442< / td > < td class = "benchmarkresult" > 522< / td > < td class = "benchmarkresult" > 645< / td > < td class = "benchmarkresult" > 1105< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 512> str; ... str += str_var1 + str_var2;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 399< / td > < td class = "benchmarkresult" > 384< / td > < td class = "benchmarkresult" > 390< / td > < td class = "benchmarkresult" > 450< / td > < td class = "benchmarkresult" > 945< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 1024> str; ... str += str_var1 + str_var2;< span class = "tooltiptext code" > template< unsigned N>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 293< / td > < td class = "benchmarkresult" > 305< / td > < td class = "benchmarkresult" > 294< / td > < td class = "benchmarkresult" > 341< / td > < td class = "benchmarkresult" > 897< / td > < / tr >
2026-01-21 11:59:17 +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 1 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::stringstream str; ... str < < str_var1 < < str_var2 ; ' , data: [ 1362 , 1367 , 4484 , 5409 , 4614 ] } ,
{name:'std::string str; ... str += str_var1 + str_var2;',data:[1379,1440,4039,3876,2454]},
{name:'lstringa< 16 > str; ... str += str_var1 + str_var2;',data:[563,539,837,901,1218]},
{name:'lstringa< 128 > str; ... str += str_var1 + str_var2;',data:[483,442,522,645,1105]},
{name:'lstringa< 512 > str; ... str += str_var1 + str_var2;',data:[399,384,390,450,945]},
{name:'lstringa< 1024 > str; ... str += str_var1 + str_var2;',data:[293,305,294,341,897]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs22" > < h4 > < a id = "bs130432147582115154460" href = "#bs130432147582115154460" > #< / a > Append text, number, text< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::stringstream str; str < < " test = " < < k < < " times" ;< span class = "tooltiptext code" > void AppendStreamStrNumStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3010< / td > < td class = "benchmarkresult" > 3038< / td > < td class = "benchmarkresult" > 10900< / td > < td class = "benchmarkresult" > 11520< / td > < td class = "benchmarkresult" > 6454< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str = " test = " + std::to_string(k) + " times" ;< span class = "tooltiptext code" > void AppendStdStringStrNumStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 483< / td > < td class = "benchmarkresult" > 455< / td > < td class = "benchmarkresult" > 1060< / td > < td class = "benchmarkresult" > 1215< / td > < td class = "benchmarkresult" > 1599< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > char buf[100]; sprintf(buf, " test = %u times" , k); std::string str = buf;< span class = "tooltiptext code" > void AppendSprintfStrNumStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1367< / td > < td class = "benchmarkresult" > 1524< / td > < td class = "benchmarkresult" > 2790< / td > < td class = "benchmarkresult" > 2811< / td > < td class = "benchmarkresult" > 2891< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string str = std::format(" test = {} times" , k);< span class = "tooltiptext code" > void AppendFormatStrNumStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1158< / td > < td class = "benchmarkresult" > 1257< / td > < td class = "benchmarkresult" > 1884< / td > < td class = "benchmarkresult" > 2384< / td > < td class = "benchmarkresult" > 2003< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 8> str; str.format(" test = {} times" , k);< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
string without allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 1453< / td > < td class = "benchmarkresult" > 1696< / td > < td class = "benchmarkresult" > 2071< / td > < td class = "benchmarkresult" > 2590< / td > < td class = "benchmarkresult" > 3067< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 32> str; str.format(" test = {} times" , k);< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
And it fits in this one. Use buffers of the appropriate size right away.< / span > < / span > < / td > < td class = "benchmarkresult" > 977< / td > < td class = "benchmarkresult" > 1059< / td > < td class = "benchmarkresult" > 1047< / td > < td class = "benchmarkresult" > 1592< / td > < td class = "benchmarkresult" > 2448< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 8> str = " test = " + k + " times" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
The result does not fit into SSO, an allocation occurs.< / span > < / span > < / td > < td class = "benchmarkresult" > 298< / td > < td class = "benchmarkresult" > 311< / td > < td class = "benchmarkresult" > 840< / td > < td class = "benchmarkresult" > 862< / td > < td class = "benchmarkresult" > 591< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > lstringa< 32> str = " test = " + k + " times" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
Once again, use appropriately sized buffers from the start.< / span > < / span > < / td > < td class = "benchmarkresult" > 158< / td > < td class = "benchmarkresult" > 165< / td > < td class = "benchmarkresult" > 159< / td > < td class = "benchmarkresult" > 179< / td > < td class = "benchmarkresult" > 364< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > stringa str = " test = " + k + " times" ;< span class = "tooltiptext code" > template< typename T>
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-01-30 14:30:09 +00:00
enough to accommodate the result, hence the long time.< / span > < / span > < / td > < td class = "benchmarkresult" > 148< / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 241< / td > < td class = "benchmarkresult" > 565< / td > < / tr >
2026-01-21 11:59:17 +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 2 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::stringstream str; str < < "test = " < < k < < " times " ; ' , data: [ 3010 , 3038 , 10900 , 11520 , 6454 ] } ,
{name:'std::string str = "test = " + std::to_string(k) + " times";',data:[483,455,1060,1215,1599]},
{name:'char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;',data:[1367,1524,2790,2811,2891]},
{name:'std::string str = std::format("test = {} times", k);',data:[1158,1257,1884,2384,2003]},
{name:'lstringa< 8 > str; str.format("test = {} times", k);',data:[1453,1696,2071,2590,3067]},
{name:'lstringa< 32 > str; str.format("test = {} times", k);',data:[977,1059,1047,1592,2448]},
{name:'lstringa< 8 > str = "test = " + k + " times";',data:[298,311,840,862,591]},
{name:'lstringa< 32 > str = "test = " + k + " times";',data:[158,165,159,179,364]},
{name:'stringa str = "test = " + k + " times";',data:[148,157,167,241,565]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs23" > < h4 > < a id = "bs7106975351756760120" href = "#bs7106975351756760120" > #< / a > Split text and convert to int< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::string::find + substr + std::strtol< span class = "tooltiptext code" > void SplitConvertIntStdString(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 290< / td > < td class = "benchmarkresult" > 266< / td > < td class = "benchmarkresult" > 535< / td > < td class = "benchmarkresult" > 554< / td > < td class = "benchmarkresult" > 637< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa::splitter + ssa::as_int< span class = "tooltiptext code" > void SplitConvertIntSimStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 156< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 158< / td > < td class = "benchmarkresult" > 297< / td > < td class = "benchmarkresult" > 291< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > ssa::splitf + functor< span class = "tooltiptext code" > void SplitConvertIntSplitf(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 209< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 191< / td > < td class = "benchmarkresult" > 217< / td > < td class = "benchmarkresult" > 324< / td > < / tr >
2026-01-21 11:59:17 +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 3 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'std::string::find + substr + std::strtol',data:[290,266,535,554,637]},
{name:'ssa::splitter + ssa::as_int',data:[156,134,158,297,291]},
{name:'ssa::splitf + functor',data:[209,129,191,217,324]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs24" > < h4 > < a id = "bs151373809886162287550" href = "#bs151373809886162287550" > #< / a > Replace symbols in text ~400 symbols< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Naive (and wrong) replace symbols with std::string find + replace< span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
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-01-30 14:30:09 +00:00
it works quickly.< / span > < / span > < / td > < td class = "benchmarkresult" > 887< / td > < td class = "benchmarkresult" > 892< / td > < td class = "benchmarkresult" > 1161< / td > < td class = "benchmarkresult" > 1311< / td > < td class = "benchmarkresult" > 3008< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace symbols with std::string find_first_of + replace< span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
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-01-30 14:30:09 +00:00
conflicting replacements.< / span > < / span > < / td > < td class = "benchmarkresult" > 2460< / td > < td class = "benchmarkresult" > 2488< / td > < td class = "benchmarkresult" > 2164< / td > < td class = "benchmarkresult" > 2239< / td > < td class = "benchmarkresult" > 4019< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace symbols with std::string_view find_first_of + copy< span class = "tooltiptext code" > void ReplaceSymbolsStdString(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1150< / td > < td class = "benchmarkresult" > 1056< / td > < td class = "benchmarkresult" > 2371< / td > < td class = "benchmarkresult" > 2515< / td > < td class = "benchmarkresult" > 3001< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace runtime symbols with string expressions and without remembering all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1280< / td > < td class = "benchmarkresult" > 1534< / td > < td class = "benchmarkresult" > 1415< / td > < td class = "benchmarkresult" > 1586< / td > < td class = "benchmarkresult" > 3241< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace runtime symbols with simstr and memorization of all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1080< / td > < td class = "benchmarkresult" > 1029< / td > < td class = "benchmarkresult" > 1318< / td > < td class = "benchmarkresult" > 1480< / td > < td class = "benchmarkresult" > 2783< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace const symbols with string expressions and without remembering all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1033< / td > < td class = "benchmarkresult" > 1217< / td > < td class = "benchmarkresult" > 1132< / td > < td class = "benchmarkresult" > 1281< / td > < td class = "benchmarkresult" > 2521< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace const symbols with string expressions and memorization of all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 891< / td > < td class = "benchmarkresult" > 860< / td > < td class = "benchmarkresult" > 1225< / td > < td class = "benchmarkresult" > 1244< / td > < td class = "benchmarkresult" > 2447< / td > < / tr >
2026-01-21 11:59:17 +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 4 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Naive (and wrong) replace symbols with std::string find + replace',data:[887,892,1161,1311,3008]},
{name:'replace symbols with std::string find_first_of + replace',data:[2460,2488,2164,2239,4019]},
{name:'replace symbols with std::string_view find_first_of + copy',data:[1150,1056,2371,2515,3001]},
{name:'replace runtime symbols with string expressions and without remembering all search results',data:[1280,1534,1415,1586,3241]},
{name:'replace runtime symbols with simstr and memorization of all search results',data:[1080,1029,1318,1480,2783]},
{name:'replace const symbols with string expressions and without remembering all search results',data:[1033,1217,1132,1281,2521]},
{name:'replace const symbols with string expressions and memorization of all search results',data:[891,860,1225,1244,2447]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs25" > < h4 > < a id = "bs96756339547767401190" href = "#bs96756339547767401190" > #< / a > Replace symbols in text ~40 symbols< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short Naive (and wrong) replace symbols with std::string find + replace< span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 164< / td > < td class = "benchmarkresult" > 331< / td > < td class = "benchmarkresult" > 331< / td > < td class = "benchmarkresult" > 436< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace symbols with std::string find_first_of + replace< span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 320< / td > < td class = "benchmarkresult" > 347< / td > < td class = "benchmarkresult" > 371< / td > < td class = "benchmarkresult" > 435< / td > < td class = "benchmarkresult" > 480< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace symbols with std::string_view find_first_of + copy< span class = "tooltiptext code" > void ShortReplaceSymbolsStdString(benchmark::State& state) {
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 164< / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 320< / td > < td class = "benchmarkresult" > 378< / td > < td class = "benchmarkresult" > 409< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace runtime symbols with string expressions and without remembering all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 179< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 258< / td > < td class = "benchmarkresult" > 325< / td > < td class = "benchmarkresult" > 396< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace runtime symbols with simstr and memorization of all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 188< / td > < td class = "benchmarkresult" > 185< / td > < td class = "benchmarkresult" > 382< / td > < td class = "benchmarkresult" > 386< / td > < td class = "benchmarkresult" > 427< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace const symbols with string expressions and without remembering all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 210< / td > < td class = "benchmarkresult" > 257< / td > < td class = "benchmarkresult" > 261< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Short replace const symbols with string expressions and memorization of all search results< span class = "tooltiptext code" > template< bool UseVector>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 143< / td > < td class = "benchmarkresult" > 149< / td > < td class = "benchmarkresult" > 319< / td > < td class = "benchmarkresult" > 347< / td > < td class = "benchmarkresult" > 299< / td > < / tr >
2026-01-21 11:59:17 +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 5 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Short Naive (and wrong) replace symbols with std::string find + replace',data:[157,164,331,331,436]},
{name:'Short replace symbols with std::string find_first_of + replace',data:[320,347,371,435,480]},
{name:'Short replace symbols with std::string_view find_first_of + copy',data:[164,168,320,378,409]},
{name:'Short replace runtime symbols with string expressions and without remembering all search results',data:[179,190,258,325,396]},
{name:'Short replace runtime symbols with simstr and memorization of all search results',data:[188,185,382,386,427]},
{name:'Short replace const symbols with string expressions and without remembering all search results',data:[139,157,210,257,261]},
{name:'Short replace const symbols with string expressions and memorization of all search results',data:[143,149,319,347,299]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs26" > < h4 > < a id = "bs77745698784557935900" href = "#bs77745698784557935900" > #< / a > Replace All Str To Longer Size< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in std::string|64< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 166< / td > < td class = "benchmarkresult" > 164< / td > < td class = "benchmarkresult" > 228< / td > < td class = "benchmarkresult" > 249< / td > < td class = "benchmarkresult" > 370< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in std::string|256< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 527< / td > < td class = "benchmarkresult" > 493< / td > < td class = "benchmarkresult" > 773< / td > < td class = "benchmarkresult" > 823< / td > < td class = "benchmarkresult" > 1328< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in std::string|512< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1047< / td > < td class = "benchmarkresult" > 980< / td > < td class = "benchmarkresult" > 1456< / td > < td class = "benchmarkresult" > 1559< / td > < td class = "benchmarkresult" > 2633< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in std::string|1024< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2576< / td > < td class = "benchmarkresult" > 2467< / td > < td class = "benchmarkresult" > 3151< / td > < td class = "benchmarkresult" > 3325< / td > < td class = "benchmarkresult" > 5569< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in std::string|2048< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6341< / td > < td class = "benchmarkresult" > 6568< / td > < td class = "benchmarkresult" > 8263< / td > < td class = "benchmarkresult" > 8393< / td > < td class = "benchmarkresult" > 12248< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in lstringa< 8>|64< span class = "tooltiptext code" > template< size_t N, size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 146< / td > < td class = "benchmarkresult" > 158< / td > < td class = "benchmarkresult" > 229< / td > < td class = "benchmarkresult" > 233< / td > < td class = "benchmarkresult" > 298< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in lstringa< 8>|256< span class = "tooltiptext code" > template< size_t N, size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 455< / td > < td class = "benchmarkresult" > 509< / td > < td class = "benchmarkresult" > 612< / td > < td class = "benchmarkresult" > 663< / td > < td class = "benchmarkresult" > 1121< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in lstringa< 8>|512< span class = "tooltiptext code" > template< size_t N, size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 815< / td > < td class = "benchmarkresult" > 916< / td > < td class = "benchmarkresult" > 1063< / td > < td class = "benchmarkresult" > 1124< / td > < td class = "benchmarkresult" > 2117< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in lstringa< 8>|1024< span class = "tooltiptext code" > template< size_t N, size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1685< / td > < td class = "benchmarkresult" > 1877< / td > < td class = "benchmarkresult" > 1863< / td > < td class = "benchmarkresult" > 2035< / td > < td class = "benchmarkresult" > 3949< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- in lstringa< 8>|2048< span class = "tooltiptext code" > template< size_t N, size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3174< / td > < td class = "benchmarkresult" > 3516< / td > < td class = "benchmarkresult" > 3465< / td > < td class = "benchmarkresult" > 3885< / td > < td class = "benchmarkresult" > 7688< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- by init stringa|64< span class = "tooltiptext code" > template< size_t Count>
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) {
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);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 98.9< / td > < td class = "benchmarkresult" > 105< / td > < td class = "benchmarkresult" > 172< / td > < td class = "benchmarkresult" > 210< / td > < td class = "benchmarkresult" > 204< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- by init stringa|256< span class = "tooltiptext code" > template< size_t Count>
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) {
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);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 304< / td > < td class = "benchmarkresult" > 305< / td > < td class = "benchmarkresult" > 390< / td > < td class = "benchmarkresult" > 512< / td > < td class = "benchmarkresult" > 730< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- by init stringa|512< span class = "tooltiptext code" > template< size_t Count>
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) {
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);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 710< / td > < td class = "benchmarkresult" > 735< / td > < td class = "benchmarkresult" > 839< / td > < td class = "benchmarkresult" > 1079< / td > < td class = "benchmarkresult" > 1709< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- by init stringa|1024< span class = "tooltiptext code" > template< size_t Count>
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) {
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);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1576< / td > < td class = "benchmarkresult" > 1627< / td > < td class = "benchmarkresult" > 1673< / td > < td class = "benchmarkresult" > 2161< / td > < td class = "benchmarkresult" > 3566< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to ---- by init stringa|2048< span class = "tooltiptext code" > template< size_t Count>
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) {
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);
}
2026-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3212< / td > < td class = "benchmarkresult" > 3391< / td > < td class = "benchmarkresult" > 3133< / td > < td class = "benchmarkresult" > 4314< / td > < td class = "benchmarkresult" > 7174< / td > < / tr >
2026-01-21 11:59:17 +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 6 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'replace bb to ---- in std::string|64',data:[166,164,228,249,370]},
{name:'replace bb to ---- in std::string|256',data:[527,493,773,823,1328]},
{name:'replace bb to ---- in std::string|512',data:[1047,980,1456,1559,2633]},
{name:'replace bb to ---- in std::string|1024',data:[2576,2467,3151,3325,5569]},
{name:'replace bb to ---- in std::string|2048',data:[6341,6568,8263,8393,12248]},
{name:'replace bb to ---- in lstringa< 8 > |64',data:[146,158,229,233,298]},
{name:'replace bb to ---- in lstringa< 8 > |256',data:[455,509,612,663,1121]},
{name:'replace bb to ---- in lstringa< 8 > |512',data:[815,916,1063,1124,2117]},
{name:'replace bb to ---- in lstringa< 8 > |1024',data:[1685,1877,1863,2035,3949]},
{name:'replace bb to ---- in lstringa< 8 > |2048',data:[3174,3516,3465,3885,7688]},
{name:'replace bb to ---- by init stringa|64',data:[98.9,105,172,210,204]},
{name:'replace bb to ---- by init stringa|256',data:[304,305,390,512,730]},
{name:'replace bb to ---- by init stringa|512',data:[710,735,839,1079,1709]},
{name:'replace bb to ---- by init stringa|1024',data:[1576,1627,1673,2161,3566]},
{name:'replace bb to ---- by init stringa|2048',data:[3212,3391,3133,4314,7174]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs27" > < h4 > < a id = "bs74494088982050398630" href = "#bs74494088982050398630" > #< / a > Replace All Str To Same Size< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in std::string|64< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 128< / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 210< / td > < td class = "benchmarkresult" > 262< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in std::string|256< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 402< / td > < td class = "benchmarkresult" > 407< / td > < td class = "benchmarkresult" > 475< / td > < td class = "benchmarkresult" > 555< / td > < td class = "benchmarkresult" > 964< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in std::string|512< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 767< / td > < td class = "benchmarkresult" > 710< / td > < td class = "benchmarkresult" > 870< / td > < td class = "benchmarkresult" > 968< / td > < td class = "benchmarkresult" > 1891< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in std::string|1024< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1542< / td > < td class = "benchmarkresult" > 1390< / td > < td class = "benchmarkresult" > 1593< / td > < td class = "benchmarkresult" > 1820< / td > < td class = "benchmarkresult" > 3703< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in std::string|2048< span class = "tooltiptext code" > template< size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2990< / td > < td class = "benchmarkresult" > 2901< / td > < td class = "benchmarkresult" > 3248< / td > < td class = "benchmarkresult" > 3593< / td > < td class = "benchmarkresult" > 7154< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in lstringa< 8>|64< span class = "tooltiptext code" > template< size_t N, size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 97.3< / td > < td class = "benchmarkresult" > 101< / td > < td class = "benchmarkresult" > 184< / td > < td class = "benchmarkresult" > 204< / td > < td class = "benchmarkresult" > 223< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in lstringa< 8>|256< span class = "tooltiptext code" > template< size_t N, size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 298< / td > < td class = "benchmarkresult" > 313< / td > < td class = "benchmarkresult" > 444< / td > < td class = "benchmarkresult" > 483< / td > < td class = "benchmarkresult" > 775< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in lstringa< 8>|512< span class = "tooltiptext code" > template< size_t N, size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 610< / td > < td class = "benchmarkresult" > 561< / td > < td class = "benchmarkresult" > 776< / td > < td class = "benchmarkresult" > 812< / td > < td class = "benchmarkresult" > 1462< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in lstringa< 8>|1024< span class = "tooltiptext code" > template< size_t N, size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1081< / td > < td class = "benchmarkresult" > 1194< / td > < td class = "benchmarkresult" > 1435< / td > < td class = "benchmarkresult" > 1490< / td > < td class = "benchmarkresult" > 2825< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- in lstringa< 8>|2048< span class = "tooltiptext code" > template< size_t N, size_t Long>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2082< / td > < td class = "benchmarkresult" > 2106< / td > < td class = "benchmarkresult" > 2934< / td > < td class = "benchmarkresult" > 2919< / td > < td class = "benchmarkresult" > 5495< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- by init stringa|64< span class = "tooltiptext code" > template< size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 82.2< / td > < td class = "benchmarkresult" > 96.9< / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 178< / td > < td class = "benchmarkresult" > 181< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- by init stringa|256< span class = "tooltiptext code" > template< size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 260< / td > < td class = "benchmarkresult" > 269< / td > < td class = "benchmarkresult" > 350< / td > < td class = "benchmarkresult" > 387< / td > < td class = "benchmarkresult" > 646< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- by init stringa|512< span class = "tooltiptext code" > template< size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 435< / td > < td class = "benchmarkresult" > 512< / td > < td class = "benchmarkresult" > 600< / td > < td class = "benchmarkresult" > 672< / td > < td class = "benchmarkresult" > 1197< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- by init stringa|1024< span class = "tooltiptext code" > template< size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 865< / td > < td class = "benchmarkresult" > 1030< / td > < td class = "benchmarkresult" > 1095< / td > < td class = "benchmarkresult" > 1246< / td > < td class = "benchmarkresult" > 2229< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > replace bb to -- by init stringa|2048< span class = "tooltiptext code" > template< size_t Count>
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-01-30 14:30:09 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1662< / td > < td class = "benchmarkresult" > 1958< / td > < td class = "benchmarkresult" > 2061< / td > < td class = "benchmarkresult" > 2307< / td > < td class = "benchmarkresult" > 4482< / td > < / tr >
2026-01-21 11:59:17 +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 7 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'replace bb to -- in std::string|64',data:[128,121,194,210,262]},
{name:'replace bb to -- in std::string|256',data:[402,407,475,555,964]},
{name:'replace bb to -- in std::string|512',data:[767,710,870,968,1891]},
{name:'replace bb to -- in std::string|1024',data:[1542,1390,1593,1820,3703]},
{name:'replace bb to -- in std::string|2048',data:[2990,2901,3248,3593,7154]},
{name:'replace bb to -- in lstringa< 8 > |64',data:[97.3,101,184,204,223]},
{name:'replace bb to -- in lstringa< 8 > |256',data:[298,313,444,483,775]},
{name:'replace bb to -- in lstringa< 8 > |512',data:[610,561,776,812,1462]},
{name:'replace bb to -- in lstringa< 8 > |1024',data:[1081,1194,1435,1490,2825]},
{name:'replace bb to -- in lstringa< 8 > |2048',data:[2082,2106,2934,2919,5495]},
{name:'replace bb to -- by init stringa|64',data:[82.2,96.9,154,178,181]},
{name:'replace bb to -- by init stringa|256',data:[260,269,350,387,646]},
{name:'replace bb to -- by init stringa|512',data:[435,512,600,672,1197]},
{name:'replace bb to -- by init stringa|1024',data:[865,1030,1095,1246,2229]},
{name:'replace bb to -- by init stringa|2048',data:[1662,1958,2061,2307,4482]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs28" > < h4 > < a id = "bs8410196985047277720" href = "#bs8410196985047277720" > #< / a > Hash Map insert and find< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > hashStrMapA< size_t> emplace & find stringa;< span class = "tooltiptext code" > void HashMapSimStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
hashStrMapA, and then search for them in it.< / span > < / span > < / td > < td class = "benchmarkresult" > 3721964< / td > < td class = "benchmarkresult" > 3615004< / td > < td class = "benchmarkresult" > 3836756< / td > < td class = "benchmarkresult" > 4177853< / td > < td class = "benchmarkresult" > 3099563< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::unordered_map< std::string, size_t> emplace & find std::string;< span class = "tooltiptext code" > void HashMapStdStr(benchmark::State& state) {
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-01-30 14:30:09 +00:00
Same thing with std::string and std::unordered_map< / span > < / span > < / td > < td class = "benchmarkresult" > 3481822< / td > < td class = "benchmarkresult" > 3642731< / td > < td class = "benchmarkresult" > 5263843< / td > < td class = "benchmarkresult" > 5291437< / td > < td class = "benchmarkresult" > 3404147< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > hashStrMapA< size_t> emplace & find ssa;< span class = "tooltiptext code" > void HashMapSimSsa(benchmark::State& state) {
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-01-30 14:30:09 +00:00
Now we insert stringa and search for ssa< / span > < / span > < / td > < td class = "benchmarkresult" > 3581196< / td > < td class = "benchmarkresult" > 3606655< / td > < td class = "benchmarkresult" > 3437345< / td > < td class = "benchmarkresult" > 3878928< / td > < td class = "benchmarkresult" > 3137768< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > std::unordered_map< std::string, size_t> emplace & find std::string_view;< span class = "tooltiptext code" > void HashMapStdStrView(benchmark::State& state) {
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-01-30 14:30:09 +00:00
We insert std::string and look for std::string_view< / span > < / span > < / td > < td class = "benchmarkresult" > 4098438< / td > < td class = "benchmarkresult" > 3902358< / td > < td class = "benchmarkresult" > 6320906< / td > < td class = "benchmarkresult" > 6508746< / td > < td class = "benchmarkresult" > 3690206< / td > < / tr >
2026-01-21 11:59:17 +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 2 8 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'hashStrMapA< size_t > emplace & find stringa;',data:[3721964,3615004,3836756,4177853,3099563]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string;',data:[3481822,3642731,5263843,5291437,3404147]},
{name:'hashStrMapA< size_t > emplace & find ssa;',data:[3581196,3606655,3437345,3878928,3137768]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string_view;',data:[4098438,3902358,6320906,6508746,3690206]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-01-21 11:59:17 +00:00
< div class = "benchset" id = "bs29" > < h4 > < a id = "bs131384792586914680410" href = "#bs131384792586914680410" > #< / a > Build Full Func Name< / h4 >
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Build func full name std::string;< span class = "tooltiptext code" > std::string build_full_name_std() const {
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-01-30 14:30:09 +00:00
return values. The algorithm uses std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 724< / td > < td class = "benchmarkresult" > 976< / td > < td class = "benchmarkresult" > 1528< / td > < td class = "benchmarkresult" > 1796< / td > < td class = "benchmarkresult" > 2929< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Build func full name std::string 1;< span class = "tooltiptext code" > std::string build_full_name_std1() const {
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-01-30 14:30:09 +00:00
+= to a string are replaced with a single += + + +.< / span > < / span > < / td > < td class = "benchmarkresult" > 818< / td > < td class = "benchmarkresult" > 1053< / td > < td class = "benchmarkresult" > 1573< / td > < td class = "benchmarkresult" > 1699< / td > < td class = "benchmarkresult" > 3048< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Build func full name std::stream;< span class = "tooltiptext code" > std::string build_full_name_stream() const {
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-01-30 14:30:09 +00:00
We construct the function name through std::ostringstream and < < < / span > < / span > < / td > < td class = "benchmarkresult" > 2574< / td > < td class = "benchmarkresult" > 2517< / td > < td class = "benchmarkresult" > 8149< / td > < td class = "benchmarkresult" > 9810< / td > < td class = "benchmarkresult" > 6964< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Build func full name stringa;< span class = "tooltiptext code" > stringa build_full_name() const {
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-01-30 14:30:09 +00:00
Parameter information is appended to the current line.< / span > < / span > < / td > < td class = "benchmarkresult" > 506< / td > < td class = "benchmarkresult" > 466< / td > < td class = "benchmarkresult" > 816< / td > < td class = "benchmarkresult" > 945< / td > < td class = "benchmarkresult" > 1410< / td > < / tr >
2025-04-05 14:21:11 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > Build func full name stringa 1;< span class = "tooltiptext code" > stringa build_full_name1() const {
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-01-30 14:30:09 +00:00
to be written in a single string, but is slightly slower in execution time.< / span > < / span > < / td > < td class = "benchmarkresult" > 741< / td > < td class = "benchmarkresult" > 694< / td > < td class = "benchmarkresult" > 1001< / td > < td class = "benchmarkresult" > 1053< / td > < td class = "benchmarkresult" > 1605< / td > < / tr >
2026-01-21 11:59:17 +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 2 9 ' , t e s t s : [
2026-01-30 14:30:09 +00:00
{name:'Build func full name std::string;',data:[724,976,1528,1796,2929]},
{name:'Build func full name std::string 1;',data:[818,1053,1573,1699,3048]},
{name:'Build func full name std::stream;',data:[2574,2517,8149,9810,6964]},
{name:'Build func full name stringa;',data:[506,466,816,945,1410]},
{name:'Build func full name stringa 1;',data:[741,694,1001,1053,1605]}
2025-11-26 19:15:50 +00:00
]}< / script > < / body > < / html >