2025-04-05 14:21:11 +00:00
< html >
< head >
< meta charset = "UTF-8" / >
< link href = "results.css" rel = "stylesheet" / >
< title > SimStr benchmarks results< / title >
< link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" > < / script >
< script src = "https://cdn.jsdelivr.net/npm/chart.js" > < / script >
< script >
let bench_sets = {};
let activeBuilder = buildTestsByPlatformsBar;
let buildAsLine = {
"Copy not literal Str with N symbols": "Length of the copied string",
"Replace All Str To Longer Size": "Length of the string to be replaced",
"Replace All Str To Same Size": "Length of the string to be replaced"
};
function hl() {
document.querySelectorAll('.tooltiptext.code').forEach((el) => {
hljs.highlightElement(el);
});
}
function addBarChart(id, data) {
let canvas = document.getElementById('chart' + id);
new Chart(canvas, {
type: 'bar',
data: data,
options: {
scales: {
y: {
beginAtZero: true
},
x: {
title: {
text: "Time (ns)",
display: true
}
}
},
indexAxis: 'y',
plugins: {
legend: {
position: 'right',
labels: {
font: {
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
}
}
}
}
}
});
}
function platformChecked(idx) {
return document.getElementById('pl' + idx).checked;
}
function buildPlatformsByTestsBar(bsName) {
if (buildAsLine[bsName]) {
buildPlatformsByTestsLine(bsName, buildAsLine[bsName]);
return;
}
let data = { labels: [], datasets: [] };
for (const i in platform_names) {
if (platformChecked(i))
data.datasets.push({ label: platform_names[i], data: [], borderWidth: 1 });
}
let bs = bench_sets[bsName];
for (const test of bs.tests) {
data.labels.push(test.name);
let ds = 0;
for (const i in test.data) {
if (platformChecked(i)) {
data.datasets[ds++].data.push(test.data[i]);
}
}
}
addBarChart(bs.id, data);
}
function buildTestsByPlatformsBar(bsName) {
if (buildAsLine[bsName], buildAsLine[bsName]) {
buildTestsByPlatformsLine(bsName, buildAsLine[bsName]);
return;
}
let data = { labels: [], datasets: [] };
let bs = bench_sets[bsName];
for (const test of bs.tests) {
data.datasets.push({ label: test.name, data: [], borderWidth: 1 });
}
for (const i in platform_names) {
if (platformChecked(i)) {
data.labels.push(platform_names[i]);
for (const j in bs.tests) {
data.datasets[j].data.push(bs.tests[j].data[i]);
}
}
}
addBarChart(bs.id, data);
}
function buildCanvas(plCount) {
document.querySelectorAll("canvas.bench_chart").forEach(e => e.remove());
for (var bs_name in bench_sets) {
let bs = bench_sets[bs_name];
if (plCount) {
let canvas = document.createElement('canvas');
canvas.id = "chart" + bs.id;
canvas.classList.add('bench_chart');
let h = 20 * plCount * bs.tests.length;
canvas.style.width = "100%";
canvas.style.height = h + "px";
canvas.height = h * devicePixelRatio;
document.getElementById(bs.id).after(canvas);
}
}
}
function addLineChart(canvas, data, title, scaleTitle) {
new Chart(canvas, {
type: 'line',
data: data,
options: {
scales: {
y: {
beginAtZero: true,
title: {
text: scaleTitle,
display: true
}
},
x: {
title: {
text: "Time (ns)",
display: true
}
}
},
indexAxis: 'y',
plugins: {
title: {
display: true,
text: title,
},
legend: {
position: 'right',
labels: {
font: {
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
}
}
}
}
}
});
}
function buildTestsByPlatformsLineOne(bs, canvas, plIdx, scaleTitle) {
let data = { datasets: [] };
let prevTest = '';
let curData = undefined;
for (const test of bs.tests) {
let m = test.name.match(/(.+)[\/\|](\d+)$/);
if (m[1] != prevTest) {
prevTest = m[1];
curData = { label: prevTest, data: [], borderWidth: 1 };
data.datasets.push(curData);
}
curData.data.push([test.data[plIdx], m[2]]);
}
addLineChart(canvas, data, platform_names[plIdx], scaleTitle);
}
function buildTestsByPlatformsLine(bsName, scaleTitle) {
let bs = bench_sets[bsName];
let canvas = document.getElementById('chart' + bs.id);
let after = null;
for (const i in platform_names) {
if (platformChecked(i)) {
if (!canvas) {
canvas = document.createElement('canvas');
canvas.classList.add('bench_chart');
canvas.style.width = "100%";
after.after(canvas);
}
canvas.style.height = "300px";
canvas.height = 300 * devicePixelRatio;
buildTestsByPlatformsLineOne(bs, canvas, i, scaleTitle);
after = canvas;
canvas = null;
}
}
}
function buildPlatformsByTestsLineOne(bs, canvas, after, testData, title, scaleTitle) {
let data = { datasets: [] };
for (const i in platform_names) {
if (platformChecked(i)) {
ds = {label: platform_names[i], data: []};
for (const test of testData) {
ds.data.push([test.data[i], test.count]);
}
data.datasets.push(ds);
}
}
if (!canvas) {
canvas = document.createElement('canvas');
canvas.classList.add('bench_chart');
canvas.style.width = "100%";
after.after(canvas);
}
canvas.style.height = "300px";
canvas.height = 300 * devicePixelRatio;
addLineChart(canvas, data, title, scaleTitle);
return canvas;
}
function buildPlatformsByTestsLine(bsName, scaleTitle) {
let bs = bench_sets[bsName];
let canvas = document.getElementById('chart' + bs.id);
let after = null;
let data = [];
let prevTest = '';
for (const test of bs.tests) {
let m = test.name.match(/(.+)[\/\|](\d+)$/);
if (m[1] != prevTest) {
if (data.length) {
after = buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
canvas = null;
}
prevTest = m[1];
data = [];
}
data.push({count: m[2], data: test.data});
}
if (data.length) {
buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
}
}
function buildCharts() {
let plCount = 0;
for (const i in platform_names) {
if (platformChecked(i))
plCount++;
}
buildCanvas(plCount);
for (var bs_name in bench_sets) {
activeBuilder(bs_name);
}
}
function switchGrouping() {
activeBuilder = document.getElementById('gbp').checked ? buildTestsByPlatformsBar : buildPlatformsByTestsBar;
buildCharts();
}
document.addEventListener('DOMContentLoaded', (event) => {
if (!hljs) {
let scriptTag = document.createElement('script');
scriptTag.src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js";
scriptTag.onload = hl;
scriptTag.onreadystatechange = hl;
document.body.appendChild(scriptTag);
} else {
hl();
}
if (!Chart) {
let scriptTag = document.createElement('script');
scriptTag.src = "https://cdn.jsdelivr.net/npm/chart.js";
scriptTag.onload = buildCharts;
scriptTag.onreadystatechange = buildCharts;
document.body.appendChild(scriptTag);
} else {
buildCharts();
}
});
< / script >
2026-02-03 07:38:21 +00:00
< / head > < body > < div class = "header" > < h2 > simstr benchmarks results< / h2 >
< div style = "font-size:16pt;margin:20px;text-align:center" > < a href = "https://github.com/orefkov/simstr" > simstr< / a > is a powerful and convenient library for productive work with strings in C++.< / div >
2025-04-05 14:21:11 +00:00
< span > All times in ns.< / span >
< span > < a href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp" > Source for benchmarks< / a > < / span >
< div > Group tests by platforms in charts: < input type = "checkbox" id = "gbp" checked onchange = "switchGrouping()" / > < / div > < div class = "test_platforms" > < h3 > Test configurations:< / h3 > < ul >
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-02-03 07:38:21 +00:00
Load Average: 0.00, 0.00, 0.00
2026-01-21 11:59:17 +00:00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl0" checked onchange = "buildCharts()" / > < / li >
2025-04-05 14:21:11 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / span > < span class = "tooltip" > 32 X 2494.22 MHz CPU s< span class = "tooltiptext" > CPU Caches:
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)
2026-02-03 07:38:21 +00:00
Load Average: 0.24, 0.68, 0.48
2026-01-21 11:59:17 +00:00
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.< / span > < / span > Include in charts: < input type = "checkbox" id = "pl1" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, Clang-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl2" checked onchange = "buildCharts()" / > < / li >
2025-11-26 19:15:50 +00:00
< li > < span class = "platform" > Xeon E5-2682 v4, Windows 10, MSVC-19< / span > < span class = "tooltip" > 32 X 2494 MHz CPU s< span class = "tooltiptext" > CPU Caches:
2025-04-05 14:21:11 +00:00
L1 Data 32 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 256 KiB (x16)
L3 Unified 40960 KiB (x1)< / span > < / span > Include in charts: < input type = "checkbox" id = "pl3" checked onchange = "buildCharts()" / > < / li >
2026-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 >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L22" > Concat std::string and number by std to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToStd(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = s1 + std::to_string(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 234< / td > < td class = "benchmarkresult" > 211< / td > < td class = "benchmarkresult" > 266< / td > < td class = "benchmarkresult" > 315< / td > < td class = "benchmarkresult" > 1022< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L33" > Concat std::string and number by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStd(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = +s1 + i + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 111< / td > < td class = "benchmarkresult" > 159< / td > < td class = "benchmarkresult" > 213< / td > < td class = "benchmarkresult" > 449< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L44" > Concat stringa and number by StrExpr to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSim(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = s1 + i + " end" ;
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringa в отличии от std::string,
вмещает в SSO 23 символа вместо 15, поэтому
в конце теста std::string приходится аллоцировать память,
а в stringa весь тест входит в SSO.
Unlike std::string, stringa
holds 23 characters in SSO instead of 15, so
at the end of the std::string test, memory has to be allocated,
2026-02-03 07:38:21 +00:00
while in stringa , the entire test is included in SSO.< / span > < / span > < / td > < td class = "benchmarkresult" > 62.4< / td > < td class = "benchmarkresult" > 72.6< / td > < td class = "benchmarkresult" > 67.5< / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 230< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L55" > Concat stringa and number by e_concat to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimConcat(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = e_concat(" " , s1, i, " end" );
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 67.8< / td > < td class = "benchmarkresult" > 79.0< / td > < td class = "benchmarkresult" > 75.4< / td > < td class = "benchmarkresult" > 119< / td > < td class = "benchmarkresult" > 239< / 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-02-03 07:38:21 +00:00
{name:'Concat std::string and number by std to std::string',data:[234,211,266,315,1022]},
{name:'Concat std::string and number by StrExpr to std::string',data:[104,111,159,213,449]},
{name:'Concat stringa and number by StrExpr to simstr::stringa',data:[62.4,72.6,67.5,121,230]},
{name:'Concat stringa and number by e_concat to simstr::stringa',data:[67.8,79.0,75.4,119,239]}
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-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L72" > Concat std::string and format hex number and literal to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToFmtHex(benchmark::State& state) {
2026-01-30 14:30:09 +00:00
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = s1 + std::format(" {:#x}" , i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 684< / td > < td class = "benchmarkresult" > 653< / td > < td class = "benchmarkresult" > 731< / td > < td class = "benchmarkresult" > 1033< / td > < td class = "benchmarkresult" > 1423< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L85" > std::format std::string and hex number by literal to std::string< / a > < span class = "tooltiptext code" > void ConcatAllFmtToHex(benchmark::State& state) {
2026-01-30 14:30:09 +00:00
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
// It is not worked for char8_t, char16_t, char32_t :(
std::string str = std::format(" {}{:#x} end" , s1, i);
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 872< / td > < td class = "benchmarkresult" > 960< / td > < td class = "benchmarkresult" > 1524< / td > < td class = "benchmarkresult" > 1841< / td > < td class = "benchmarkresult" > 1601< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L97" > Concat std::string and std::to_chars and string to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToCharsHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
2026-01-30 14:30:09 +00:00
// it worked only for char :(
char buf[40];
size_t len = std::to_chars(buf, buf + std::size(buf), i, 16).ptr - buf;
std::string str = s1 + " 0x" + std::string(buf, len) + " end" ;
2026-01-21 11:59:17 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 203< / td > < td class = "benchmarkresult" > 197< / td > < td class = "benchmarkresult" > 191< / td > < td class = "benchmarkresult" > 251< / td > < td class = "benchmarkresult" > 640< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L113" > Concat std::string and hex number and literal by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStdHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
std::string s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-01-21 11:59:17 +00:00
std::string str = +s1 + e_hex< HexFlags::Short>(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 142< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 80.0< / td > < td class = "benchmarkresult" > 119< / td > < td class = "benchmarkresult" > 422< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L126" > Concat stringa and hex number and literal by StrExpr to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHex(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
stra s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-01-21 11:59:17 +00:00
stringa str = s1 + e_hex< HexFlags::Short>(i) + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 124< / td > < td class = "benchmarkresult" > 75.0< / td > < td class = "benchmarkresult" > 99.3< / td > < td class = "benchmarkresult" > 212< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L139" > Concat stringa and hex number and literal by e_concat to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexC(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
stra s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
2026-01-30 14:30:09 +00:00
// Can work for all types of symbols
2026-01-29 20:48:41 +00:00
stringa str = e_concat(" " , s1, e_hex< HexFlags::Short>(i), " end" );
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 80.4< / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 213< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L152" > Subst stringa and hex number by e_subst literal to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexS(benchmark::State& state) {
2026-01-29 20:48:41 +00:00
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
stra s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
2026-02-03 07:38:21 +00:00
stringa str = e_subst(" {}{} end" , s1, e_hex< HexFlags::Short>(i));
2026-01-29 20:48:41 +00:00
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 216< / td > < td class = "benchmarkresult" > 173< / td > < td class = "benchmarkresult" > 148< / td > < td class = "benchmarkresult" > 175< / td > < td class = "benchmarkresult" > 486< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L164" > Subst stringa and hex number by e_vsubst stra to simstr::stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimHexVS(benchmark::State& state) {
2026-01-31 14:24:12 +00:00
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
stra s1 = " art " ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = e_vsubst(" {}{} end" _ss, s1, e_hex< HexFlags::Short>(i));
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 321< / td > < td class = "benchmarkresult" > 284< / td > < td class = "benchmarkresult" > 295< / td > < td class = "benchmarkresult" > 349< / td > < td class = "benchmarkresult" > 773< / 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-02-03 07:38:21 +00:00
{name:'Concat std::string and format hex number and literal to std::string',data:[684,653,731,1033,1423]},
{name:'std::format std::string and hex number by literal to std::string',data:[872,960,1524,1841,1601]},
{name:'Concat std::string and std::to_chars and string to std::string',data:[203,197,191,251,640]},
{name:'Concat std::string and hex number and literal by StrExpr to std::string',data:[142,127,80.0,119,422]},
{name:'Concat stringa and hex number and literal by StrExpr to simstr::stringa',data:[124,124,75.0,99.3,212]},
{name:'Concat stringa and hex number and literal by e_concat to simstr::stringa',data:[126,134,80.4,104,213]},
{name:'Subst stringa and hex number by e_subst literal to simstr::stringa',data:[216,173,148,175,486]},
{name:'Subst stringa and hex number by e_vsubst stra to simstr::stringa',data:[321,284,295,349,773]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs3" > < h4 > < a id = "bs147607714415450897940" href = "#bs147607714415450897940" > #< / a > format/vformat and subst/vsubst octal number< / 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-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L186" > e_subst(" art {} end" , e_int< 8, f::w< 10> | f::p | f::z>(i))< / a > < span class = "tooltiptext code" > void SubstSimToSimBin(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
static bool first = true;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
stringa str = e_subst(" art {} end" , e_int< 8, f::w< 10> | f::p | f::z>(i));
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 145< / td > < td class = "benchmarkresult" > 162< / td > < td class = "benchmarkresult" > 206< / td > < td class = "benchmarkresult" > 641< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L196" > std::format(" art {:#010o} end" , i)< / a > < span class = "tooltiptext code" > void FormatStdToStdBin(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::string str = std::format(" art {:#010o} end" , i);
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1004< / td > < td class = "benchmarkresult" > 1261< / td > < td class = "benchmarkresult" > 1369< / td > < td class = "benchmarkresult" > 1678< / td > < td class = "benchmarkresult" > 1750< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L205" > e_vsubst(pattern, e_int< 8, f::w< 10> | f::p | f::z>(i))< / a > < span class = "tooltiptext code" > void VSubstSimToSimBin(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
ssa pattern = " art {} end" ;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
stringa str = e_vsubst(pattern, e_int< 8, f::w< 10> | f::p | f::z>(i));
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 363< / td > < td class = "benchmarkresult" > 341< / td > < td class = "benchmarkresult" > 305< / td > < td class = "benchmarkresult" > 354< / td > < td class = "benchmarkresult" > 1016< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L215" > std::vformat(pattern, std::make_format_args(i))< / a > < span class = "tooltiptext code" > void VFormatStdToStdBin(benchmark::State& state) {
2026-02-03 07:38:21 +00:00
std::string_view pattern = " art {:#010o} end" ;
static bool first = true;
for (auto _: state) {
for (unsigned i = 1; i < = 100' 000; i *= 10) {
std::string str = std::vformat(pattern, std::make_format_args(i));
benchmark::DoNotOptimize(str);
}
}
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1024< / td > < td class = "benchmarkresult" > 1132< / td > < td class = "benchmarkresult" > 1373< / td > < td class = "benchmarkresult" > 1656< / td > < td class = "benchmarkresult" > 1747< / td > < / tr >
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' f o r m a t / v f o r m a t a n d s u b s t / v s u b s t o c t a l n u m b e r ' ] = { i d : ' b s 3 ' , t e s t s : [
{name:'e_subst("art {} end", e_int< 8 , f::w < 10 > | f::p | f::z>(i))',data:[168,145,162,206,641]},
{name:'std::format("art {:#010o} end", i)',data:[1004,1261,1369,1678,1750]},
{name:'e_vsubst(pattern, e_int< 8 , f::w < 10 > | f::p | f::z>(i))',data:[363,341,305,354,1016]},
{name:'std::vformat(pattern, std::make_format_args(i))',data:[1024,1132,1373,1656,1747]}
]}< / script >
< div class = "benchset" id = "bs4" > < h4 > < a id = "bs59672599204338055190" href = "#bs59672599204338055190" > #< / a > Concatenate string + " Literal" < / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L231" > Concat std::string by std to std::string< / a > < span class = "tooltiptext code" > void ConcatStdToStdS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 55.8< / td > < td class = "benchmarkresult" > 52.0< / td > < td class = "benchmarkresult" > 40.9< / td > < td class = "benchmarkresult" > 55.0< / td > < td class = "benchmarkresult" > 96.4< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L242" > Concat std::string by StrExpr to std::string< / a > < span class = "tooltiptext code" > void ConcatSimToStdS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
std::string s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
std::string str = +s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 39.5< / td > < td class = "benchmarkresult" > 35.8< / td > < td class = "benchmarkresult" > 40.7< / td > < td class = "benchmarkresult" > 75.6< / td > < td class = "benchmarkresult" > 111< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L253" > Concat stringa by StrExpr to stringa< / a > < span class = "tooltiptext code" > void ConcatSimToSimS(benchmark::State& state) {
2026-01-21 11:59:17 +00:00
stra s1 = " start " ;
for (auto _: state) {
for (int i = 1; i < = 100' 000; i *= 10) {
benchmark::DoNotOptimize(s1);
stringa str = s1 + " end" ;
benchmark::DoNotOptimize(str);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 26.1< / td > < td class = "benchmarkresult" > 27.7< / td > < td class = "benchmarkresult" > 29.0< / td > < td class = "benchmarkresult" > 52.0< / td > < td class = "benchmarkresult" > 101< / td > < / tr >
< / 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 4 ' , t e s t s : [
{name:'Concat std::string by std to std::string',data:[55.8,52.0,40.9,55.0,96.4]},
{name:'Concat std::string by StrExpr to std::string',data:[39.5,35.8,40.7,75.6,111]},
{name:'Concat stringa by StrExpr to stringa',data:[26.1,27.7,29.0,52.0,101]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs5" > < h4 > < a id = "bs68116594352702954700" href = "#bs68116594352702954700" > #< / a > Find three concatenated string in string_view< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L269" > Find concat three std::string< / a > < span class = "tooltiptext code" > size_t find_pos_str(std::string_view src, std::string_view name) {
2026-01-21 11:59:17 +00:00
// before C++26 we can not concatenate string and string_view...
return src.find(" \n- " s + std::string{name} + " -\n" );
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 113< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 204< / td > < td class = "benchmarkresult" > 230< / td > < td class = "benchmarkresult" > 149< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L274" > Find concat three strexpr< / a > < span class = "tooltiptext code" > size_t find_pos_exp(ssa src, ssa name) {
2026-01-21 11:59:17 +00:00
return src.find(std::string{" \n- " + name + " -\n" });
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 48.0< / td > < td class = "benchmarkresult" > 54.9< / td > < td class = "benchmarkresult" > 113< / td > < td class = "benchmarkresult" > 129< / td > < td class = "benchmarkresult" > 106< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L278" > Find concat three simstr< / a > < span class = "tooltiptext code" > size_t find_pos_sim(ssa src, ssa name) {
2026-01-21 11:59:17 +00:00
return src.find(lstringa< 200>{" \n- " + name + " -\n" });
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Если результат конкатенации меньше 207 символов,
он собирается в буфере на стеке, без аллокации и деалокации.
If the concatenation result is less than 207 characters,
2026-02-03 07:38:21 +00:00
it is collected in a stack-based buffer, without allocation or deallocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 19.7< / td > < td class = "benchmarkresult" > 33.1< / td > < td class = "benchmarkresult" > 21.3< / td > < td class = "benchmarkresult" > 28.3< / td > < td class = "benchmarkresult" > 73.1< / td > < / tr >
< / 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 5 ' , t e s t s : [
{name:'Find concat three std::string',data:[113,129,204,230,149]},
{name:'Find concat three strexpr',data:[48.0,54.9,113,129,106]},
{name:'Find concat three simstr',data:[19.7,33.1,21.3,28.3,73.1]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs6" > < h4 > < a id = "bs145290966789248325200" href = "#bs145290966789248325200" > #< / a > Build Type Name< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L338" > BuildTypeNameStr 0/0< / a > < span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.51< / td > < td class = "benchmarkresult" > 10.2< / td > < td class = "benchmarkresult" > 8.16< / td > < td class = "benchmarkresult" > 17.6< / td > < td class = "benchmarkresult" > 18.0< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L350" > BuildTypeNameExp 0/0< / a > < span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.39< / td > < td class = "benchmarkresult" > 6.44< / td > < td class = "benchmarkresult" > 7.66< / td > < td class = "benchmarkresult" > 14.0< / td > < td class = "benchmarkresult" > 17.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L357" > BuildTypeNameSim 0/0< / a > < span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.20< / td > < td class = "benchmarkresult" > 5.14< / td > < td class = "benchmarkresult" > 7.73< / td > < td class = "benchmarkresult" > 14.8< / td > < td class = "benchmarkresult" > 15.6< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L338" > BuildTypeNameStr 10/10< / a > < span class = "tooltiptext code" > std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
std::string res{type_name};
if (prec) {
res += " (" + std::to_string(prec);
if (scale) {
res += " ," + std::to_string(scale);
}
res += " )" ;
}
return res;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 65.6< / td > < td class = "benchmarkresult" > 85.1< / td > < td class = "benchmarkresult" > 59.7< / td > < td class = "benchmarkresult" > 79.7< / td > < td class = "benchmarkresult" > 296< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L350" > BuildTypeNameExp 10/10< / a > < span class = "tooltiptext code" > std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 33.7< / td > < td class = "benchmarkresult" > 26.5< / td > < td class = "benchmarkresult" > 32.4< / td > < td class = "benchmarkresult" > 37.9< / td > < td class = "benchmarkresult" > 106< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L357" > BuildTypeNameSim 10/10< / a > < span class = "tooltiptext code" > stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
2026-01-21 11:59:17 +00:00
if (prec) {
return type_name + " (" + prec + e_if(scale, " ," _ss + scale) + " )" ;
}
return type_name;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.1< / td > < td class = "benchmarkresult" > 22.4< / td > < td class = "benchmarkresult" > 25.6< / td > < td class = "benchmarkresult" > 37.6< / td > < td class = "benchmarkresult" > 72.9< / td > < / tr >
< / 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 6 ' , t e s t s : [
{name:'BuildTypeNameStr 0/0',data:[7.51,10.2,8.16,17.6,18.0]},
{name:'BuildTypeNameExp 0/0',data:[6.39,6.44,7.66,14.0,17.5]},
{name:'BuildTypeNameSim 0/0',data:[4.20,5.14,7.73,14.8,15.6]},
{name:'BuildTypeNameStr 10/10',data:[65.6,85.1,59.7,79.7,296]},
{name:'BuildTypeNameExp 10/10',data:[33.7,26.5,32.4,37.9,106]},
{name:'BuildTypeNameSim 10/10',data:[23.1,22.4,25.6,37.6,72.9]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs7" > < h4 > < a id = "bs54035654251116789780" href = "#bs54035654251116789780" > #< / a > Replace string by copy< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L411" > Concat with replace str< / a > < span class = "tooltiptext code" > std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
2026-01-21 11:59:17 +00:00
auto str_replace = [](std::string_view from, std::string_view pattern, std::string_view repl) {
std::string result;
for (size_t offset = 0; ;) {
size_t pos = from.find(pattern, offset);
if (pos == std::string::npos) {
result += from.substr(offset);
break;
}
result += from.substr(offset, pos - offset);
result += repl;
offset = pos + pattern.length();
}
return result;
};
return " < " + str_replace(from, pattern, repl) + " >" ;
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 210< / td > < td class = "benchmarkresult" > 228< / td > < td class = "benchmarkresult" > 349< / td > < td class = "benchmarkresult" > 341< / td > < td class = "benchmarkresult" > 496< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L429" > Concat with replace exp< / a > < span class = "tooltiptext code" > std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
2026-01-21 11:59:17 +00:00
return " < " + e_repl(from, pattern, repl) + " >" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr строковое выражение для замены подстрок
есть "из коробки".
2026-02-03 07:38:21 +00:00
simstr has a string expression for replacing substrings out of the box.< / span > < / span > < / td > < td class = "benchmarkresult" > 138< / td > < td class = "benchmarkresult" > 133< / td > < td class = "benchmarkresult" > 229< / td > < td class = "benchmarkresult" > 224< / td > < td class = "benchmarkresult" > 284< / td > < / tr >
< / 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 7 ' , t e s t s : [
{name:'Concat with replace str',data:[210,228,349,341,496]},
{name:'Concat with replace exp',data:[138,133,229,224,284]}
2026-01-21 11:59:17 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs8" > < h4 > < a id = "bs77666948964429305550" href = "#bs77666948964429305550" > #< / a > Create Empty Str< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > std::string e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Пустые строки, ничего необычного.
2026-02-03 07:38:21 +00:00
Empty lines, nothing unusual.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 2.22< / td > < td class = "benchmarkresult" > 2.16< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > std::string_view e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.365< / td > < td class = "benchmarkresult" > 0.733< / td > < td class = "benchmarkresult" > 0.364< / td > < td class = "benchmarkresult" > 1.88< / td > < td class = "benchmarkresult" > 0.989< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > ssa e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.363< / td > < td class = "benchmarkresult" > 0.182< / td > < td class = "benchmarkresult" > 0.357< / td > < td class = "benchmarkresult" > 1.47< / td > < td class = "benchmarkresult" > 0.945< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > stringa e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.730< / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.742< / td > < td class = "benchmarkresult" > 2.20< / td > < td class = "benchmarkresult" > 2.16< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > lstringa< 20> e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.13< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.55< / td > < td class = "benchmarkresult" > 2.22< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L463" > lstringa< 40> e;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateEmpty(benchmark::State& state) {
for (auto _: state) {
T empty_string;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 2.54< / td > < / tr >
< / 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 8 ' , t e s t s : [
{name:'std::string e;',data:[1.09,1.11,1.13,2.22,2.16]},
{name:'std::string_view e;',data:[0.365,0.733,0.364,1.88,0.989]},
{name:'ssa e;',data:[0.363,0.182,0.357,1.47,0.945]},
{name:'stringa e;',data:[0.730,0.738,0.742,2.20,2.16]},
{name:'lstringa< 20 > e;',data:[1.13,1.12,1.11,2.55,2.22]},
{name:'lstringa< 40 > e;',data:[1.14,1.12,1.11,2.57,2.54]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs9" > < h4 > < a id = "bs181001525395597238060" href = "#bs181001525395597238060" > #< / a > Create Str from short literal (9 symbols)< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > std::string e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Короткий литерал помещается во внутренний буфер std::string,
2026-01-21 11:59:17 +00:00
время тратится только на копирование 10 байтов.
The short literal is placed in the internal std::string buffer;
2026-02-03 07:38:21 +00:00
time is spent only copying 10 bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.99< / td > < td class = "benchmarkresult" > 1.80< / td > < td class = "benchmarkresult" > 2.60< / td > < td class = "benchmarkresult" > 2.29< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > std::string_view e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И string_view, и ssa - по сути одно и то же:
2026-01-21 11:59:17 +00:00
указатель на текст и е г о длина.
Both string_view and ssa are essentially the same thing:
2026-02-03 07:38:21 +00:00
a pointer to text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.734< / td > < td class = "benchmarkresult" > 0.778< / td > < td class = "benchmarkresult" > 0.730< / td > < td class = "benchmarkresult" > 1.79< / td > < td class = "benchmarkresult" > 1.24< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > ssa e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.372< / td > < td class = "benchmarkresult" > 0.747< / td > < td class = "benchmarkresult" > 0.368< / td > < td class = "benchmarkresult" > 1.79< / td > < td class = "benchmarkresult" > 0.976< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > stringa e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringa при инициализации константным литералом так же
2026-01-21 11:59:17 +00:00
сохраняет только указатель на текст и е г о длину.
When initialized with a constant literal, stringa also stores
2026-02-03 07:38:21 +00:00
only a pointer to the text and its length.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 2.21< / td > < td class = "benchmarkresult" > 2.22< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > lstringa< 20> e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Внутреннего буфера хватает для размещения символов,
2026-01-21 11:59:17 +00:00
время уходит только на копирование байтов.
The internal buffer is sufficient to accommodate characters;
2026-02-03 07:38:21 +00:00
time is spent only on copying bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.85< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 2.62< / td > < td class = "benchmarkresult" > 2.64< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L478" > lstringa< 40> e = " Test text" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateShortLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string = TEST_TEXT;
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1.89< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 2.57< / td > < td class = "benchmarkresult" > 2.65< / td > < / tr >
< / 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 9 ' , t e s t s : [
{name:'std::string e = "Test text";',data:[1.83,1.99,1.80,2.60,2.29]},
{name:'std::string_view e = "Test text";',data:[0.734,0.778,0.730,1.79,1.24]},
{name:'ssa e = "Test text";',data:[0.372,0.747,0.368,1.79,0.976]},
{name:'stringa e = "Test text";',data:[1.11,1.09,1.11,2.21,2.22]},
{name:'lstringa< 20 > e = "Test text";',data:[1.85,1.83,1.84,2.62,2.64]},
{name:'lstringa< 40 > e = "Test text";',data:[1.89,1.84,1.83,2.57,2.65]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs10" > < h4 > < a id = "bs132333183298742730280" href = "#bs132333183298742730280" > #< / a > Create Str from long literal (30 symbols)< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > std::string e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вот тут уже литерал не помещается во внутренний буфер,
возникает аллокация и копирование 30-и байтов.
2026-01-21 11:59:17 +00:00
Н о как же отстает аллокация под Windows от Linux'а , 20 vs 70 ns...
Here, the literal doesn't fit into the internal buffer,
and 30 bytes are allocated and copied.
2026-02-03 07:38:21 +00:00
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...< / span > < / span > < / td > < td class = "benchmarkresult" > 19.3< / td > < td class = "benchmarkresult" > 19.0< / td > < td class = "benchmarkresult" > 70.1< / td > < td class = "benchmarkresult" > 80.2< / td > < td class = "benchmarkresult" > 16.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > std::string_view e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > string_view и ssa по прежнему ничего не делают, кроме
2026-01-21 11:59:17 +00:00
запоминания указателя на текст и е г о размера.
string_view and ssa still do nothing except
2026-02-03 07:38:21 +00:00
remember the pointer to the text and its size.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.739< / td > < td class = "benchmarkresult" > 0.735< / td > < td class = "benchmarkresult" > 0.757< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 1.23< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > ssa e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.386< / td > < td class = "benchmarkresult" > 0.722< / td > < td class = "benchmarkresult" > 0.391< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 0.976< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > stringa e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > stringa на константных литералах не отстает!
2026-02-03 07:38:21 +00:00
stringa doesn't lag behind on constant literals!< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 2.52< / td > < td class = "benchmarkresult" > 2.27< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > lstringa< 20> e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > lstringa< 20 > может вместить в себя до 23 символов,
2026-01-21 11:59:17 +00:00
Очевидно, что для 30-и символов уже нужна аллокация.
2026-02-03 07:38:21 +00:00
Obviously, 30 characters already require allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 21.7< / td > < td class = "benchmarkresult" > 20.3< / td > < td class = "benchmarkresult" > 76.9< / td > < td class = "benchmarkresult" > 77.3< / td > < td class = "benchmarkresult" > 17.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L493" > lstringa< 40> e = " 123456789012345678901234567890" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CreateLongLiteral(benchmark::State& state) {
for (auto _: state) {
T empty_string{LONG_TEXT};
benchmark::DoNotOptimize(empty_string);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А в lstringa< 40 > влезает до 47 символов, так что просто
2026-01-21 11:59:17 +00:00
копируется 30 байтов.
And lstringa< 40 > can hold up to 47 characters, so 30
2026-02-03 07:38:21 +00:00
bytes are simply copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 2.60< / td > < td class = "benchmarkresult" > 1.83< / td > < td class = "benchmarkresult" > 2.56< / td > < td class = "benchmarkresult" > 3.30< / td > < td class = "benchmarkresult" > 3.01< / td > < / tr >
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' C r e a t e S t r f r o m l o n g l i t e r a l ( 3 0 s y m b o l s ) ' ] = { i d : ' b s 1 0 ' , t e s t s : [
{name:'std::string e = "123456789012345678901234567890";',data:[19.3,19.0,70.1,80.2,16.3]},
{name:'std::string_view e = "123456789012345678901234567890";',data:[0.739,0.735,0.757,1.82,1.23]},
{name:'ssa e = "123456789012345678901234567890";',data:[0.386,0.722,0.391,1.84,0.976]},
{name:'stringa e = "123456789012345678901234567890";',data:[1.12,1.09,1.12,2.52,2.27]},
{name:'lstringa< 20 > e = "123456789012345678901234567890";',data:[21.7,20.3,76.9,77.3,17.1]},
{name:'lstringa< 40 > e = "123456789012345678901234567890";',data:[2.60,1.83,2.56,3.30,3.01]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs11" > < h4 > < a id = "bs6234433963744178700" href = "#bs6234433963744178700" > #< / a > Create copy of Str with 9 symbols< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > std::string e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Строка в пределах SSO, так что просто копирует байты.
2026-02-03 07:38:21 +00:00
The string is within the SSO, so it just copies the bytes.< / span > < / span > < / td > < td class = "benchmarkresult" > 6.07< / td > < td class = "benchmarkresult" > 4.88< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 5.24< / td > < td class = "benchmarkresult" > 2.21< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > std::string_view e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.382< / td > < td class = "benchmarkresult" > 0.378< / td > < td class = "benchmarkresult" > 0.369< / td > < td class = "benchmarkresult" > 2.91< / td > < td class = "benchmarkresult" > 1.24< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > ssa e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > ssa и string_view не владеют строкой, копируется
2026-01-21 11:59:17 +00:00
только информация о строке.
ssa and string_view don't own the string; only the
2026-02-03 07:38:21 +00:00
string information is copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 0.367< / td > < td class = "benchmarkresult" > 0.375< / td > < td class = "benchmarkresult" > 0.365< / td > < td class = "benchmarkresult" > 2.88< / td > < td class = "benchmarkresult" > 1.23< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > stringa e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Копирование stringa происходит быстро,
2026-01-21 11:59:17 +00:00
особенно если она инициализирована литералом.
Copying a stringa is fast,
2026-02-03 07:38:21 +00:00
especially if it is initialized with a literal.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.09< / td > < td class = "benchmarkresult" > 1.28< / td > < td class = "benchmarkresult" > 4.09< / td > < td class = "benchmarkresult" > 2.64< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > lstringa< 20> e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В обоих случаях хватает внутреннего буфера.
2026-02-03 07:38:21 +00:00
In both cases, the internal buffer is sufficient.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.12< / td > < td class = "benchmarkresult" > 4.52< / td > < td class = "benchmarkresult" > 4.77< / td > < td class = "benchmarkresult" > 7.60< / td > < td class = "benchmarkresult" > 15.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L508" > lstringa< 40> e = " Test text" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyShortString(benchmark::State& state) {
T x{TEST_TEXT};
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Только копируются байты.
2026-02-03 07:38:21 +00:00
Only bytes are copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.37< / td > < td class = "benchmarkresult" > 4.45< / td > < td class = "benchmarkresult" > 4.89< / td > < td class = "benchmarkresult" > 8.37< / td > < td class = "benchmarkresult" > 14.8< / td > < / tr >
< / 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 1 ' , t e s t s : [
{name:'std::string e = "Test text"; auto c{e};',data:[6.07,4.88,1.82,5.24,2.21]},
{name:'std::string_view e = "Test text"; auto c{e};',data:[0.382,0.378,0.369,2.91,1.24]},
{name:'ssa e = "Test text"; auto c{e};',data:[0.367,0.375,0.365,2.88,1.23]},
{name:'stringa e = "Test text"; auto c{e};',data:[1.12,1.09,1.28,4.09,2.64]},
{name:'lstringa< 20 > e = "Test text"; auto c{e};',data:[4.12,4.52,4.77,7.60,15.5]},
{name:'lstringa< 40 > e = "Test text"; auto c{e};',data:[4.37,4.45,4.89,8.37,14.8]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs12" > < h4 > < a id = "bs76384575499199461500" href = "#bs76384575499199461500" > #< / a > Create copy of Str with 30 symbols< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > std::string e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Копирования длинной строки вызывает аллокацию,
2026-01-21 11:59:17 +00:00
SSO уже не хватает. И снова как же отстаёт аллокация под Windows...
Copying a long string causes allocations,
2026-02-03 07:38:21 +00:00
SSO is no longer sufficient. And again, how allocation lags under Windows...< / span > < / span > < / td > < td class = "benchmarkresult" > 20.1< / td > < td class = "benchmarkresult" > 23.5< / td > < td class = "benchmarkresult" > 70.6< / td > < td class = "benchmarkresult" > 77.9< / td > < td class = "benchmarkresult" > 36.8< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > std::string_view e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.732< / td > < td class = "benchmarkresult" > 0.738< / td > < td class = "benchmarkresult" > 0.726< / td > < td class = "benchmarkresult" > 2.04< / td > < td class = "benchmarkresult" > 1.25< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > ssa e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 0.376< / td > < td class = "benchmarkresult" > 0.745< / td > < td class = "benchmarkresult" > 0.362< / td > < td class = "benchmarkresult" > 2.07< / td > < td class = "benchmarkresult" > 0.975< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > stringa e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А вот у stringa копирование литерала не зависит от е г о длины,
2026-01-21 11:59:17 +00:00
сравни с предыдущим бенчмарком.
But with stringa, literal copying doesn't depend on its length,
2026-02-03 07:38:21 +00:00
compare with the previous benchmark.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.15< / td > < td class = "benchmarkresult" > 1.21< / td > < td class = "benchmarkresult" > 1.82< / td > < td class = "benchmarkresult" > 2.94< / td > < td class = "benchmarkresult" > 2.24< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > lstringa< 20> e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Н е влезает, аллокация.
2026-02-03 07:38:21 +00:00
Doesn't fit, allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 21.5< / td > < td class = "benchmarkresult" > 22.4< / td > < td class = "benchmarkresult" > 77.5< / td > < td class = "benchmarkresult" > 80.5< / td > < td class = "benchmarkresult" > 15.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L525" > lstringa< 40> e = " 123456789012345678901234567890" ; auto c{e};< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyLongString(benchmark::State& state) {
T x = LONG_TEXT;
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Уложили во внутренний буфер.
2026-02-03 07:38:21 +00:00
Placed in the internal buffer.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.04< / td > < td class = "benchmarkresult" > 5.09< / td > < td class = "benchmarkresult" > 4.61< / td > < td class = "benchmarkresult" > 6.81< / td > < td class = "benchmarkresult" > 14.8< / td > < / tr >
< / 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 2 ' , t e s t s : [
{name:'std::string e = "123456789012345678901234567890"; auto c{e};',data:[20.1,23.5,70.6,77.9,36.8]},
{name:'std::string_view e = "123456789012345678901234567890"; auto c{e};',data:[0.732,0.738,0.726,2.04,1.25]},
{name:'ssa e = "123456789012345678901234567890"; auto c{e};',data:[0.376,0.745,0.362,2.07,0.975]},
{name:'stringa e = "123456789012345678901234567890"; auto c{e};',data:[1.15,1.21,1.82,2.94,2.24]},
{name:'lstringa< 20 > e = "123456789012345678901234567890"; auto c{e};',data:[21.5,22.4,77.5,80.5,15.9]},
{name:'lstringa< 40 > e = "123456789012345678901234567890"; auto c{e};',data:[4.04,5.09,4.61,6.81,14.8]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs13" > < h4 > < a id = "bs21623892135774528620" href = "#bs21623892135774528620" > #< / a > Find 9 symbols text in end of 99 symbols text< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > std::string::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь "победила дружба", у всех типов по колонке примерно одинаково.
2026-01-21 11:59:17 +00:00
Однако, Windows и Linux явно в разных весовых категориях.
Here, "friendship wins," with all types scoring roughly equally.
2026-02-03 07:38:21 +00:00
However, Windows and Linux are clearly in different weight classes.< / span > < / span > < / td > < td class = "benchmarkresult" > 6.67< / td > < td class = "benchmarkresult" > 6.94< / td > < td class = "benchmarkresult" > 40.9< / td > < td class = "benchmarkresult" > 43.7< / td > < td class = "benchmarkresult" > 44.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > std::string_view::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.81< / td > < td class = "benchmarkresult" > 6.66< / td > < td class = "benchmarkresult" > 38.2< / td > < td class = "benchmarkresult" > 42.1< / td > < td class = "benchmarkresult" > 51.6< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > ssa::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.11< / td > < td class = "benchmarkresult" > 6.57< / td > < td class = "benchmarkresult" > 19.1< / td > < td class = "benchmarkresult" > 22.2< / td > < td class = "benchmarkresult" > 49.0< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > stringa::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.18< / td > < td class = "benchmarkresult" > 6.68< / td > < td class = "benchmarkresult" > 17.5< / td > < td class = "benchmarkresult" > 30.3< / td > < td class = "benchmarkresult" > 51.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > lstringa< 20>::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 7.10< / td > < td class = "benchmarkresult" > 6.60< / td > < td class = "benchmarkresult" > 18.2< / td > < td class = "benchmarkresult" > 20.4< / td > < td class = "benchmarkresult" > 43.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L542" > lstringa< 40>::find;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void Find(benchmark::State& state) {
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
for (auto _: state) {
int i = (int)x.find(TEST_TEXT);
#ifdef CHECK_RESULT
if (i != 90) {
state.SkipWithError(" not find?" );
break;
}
#endif
benchmark::DoNotOptimize(i);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.69< / td > < td class = "benchmarkresult" > 6.83< / td > < td class = "benchmarkresult" > 17.4< / td > < td class = "benchmarkresult" > 22.4< / td > < td class = "benchmarkresult" > 44.6< / td > < / tr >
< / 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 3 ' , t e s t s : [
{name:'std::string::find;',data:[6.67,6.94,40.9,43.7,44.9]},
{name:'std::string_view::find;',data:[7.81,6.66,38.2,42.1,51.6]},
{name:'ssa::find;',data:[7.11,6.57,19.1,22.2,49.0]},
{name:'stringa::find;',data:[7.18,6.68,17.5,30.3,51.1]},
{name:'lstringa< 20 > ::find;',data:[7.10,6.60,18.2,20.4,43.9]},
{name:'lstringa< 40 > ::find;',data:[6.69,6.83,17.4,22.4,44.6]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs14" > < h4 > < a id = "bs170792414351801782640" href = "#bs170792414351801782640" > #< / a > Copy not literal Str with N symbols< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.61< / td > < td class = "benchmarkresult" > 5.53< / td > < td class = "benchmarkresult" > 1.84< / td > < td class = "benchmarkresult" > 5.04< / td > < td class = "benchmarkresult" > 35.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Явно виден скачок, где заканчивается SSO и начинается аллокация.
Обратите внимание, что WASM - 32-битный, и там размер
2026-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-02-03 07:38:21 +00:00
smaller, as far as I remember: 11 characters + 0.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.0< / td > < td class = "benchmarkresult" > 23.7< / td > < td class = "benchmarkresult" > 79.1< / td > < td class = "benchmarkresult" > 81.5< / td > < td class = "benchmarkresult" > 35.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Дальше просто добавляется время на копирование байтов.
2026-02-03 07:38:21 +00:00
Then the time for copying bytes is simply added.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.0< / td > < td class = "benchmarkresult" > 23.4< / td > < td class = "benchmarkresult" > 78.4< / td > < td class = "benchmarkresult" > 81.8< / td > < td class = "benchmarkresult" > 36.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.9< / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 78.1< / td > < td class = "benchmarkresult" > 82.5< / td > < td class = "benchmarkresult" > 37.4< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 22.4< / td > < td class = "benchmarkresult" > 23.4< / td > < td class = "benchmarkresult" > 79.2< / td > < td class = "benchmarkresult" > 86.1< / td > < td class = "benchmarkresult" > 41.8< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.1< / td > < td class = "benchmarkresult" > 22.4< / td > < td class = "benchmarkresult" > 80.3< / td > < td class = "benchmarkresult" > 87.9< / td > < td class = "benchmarkresult" > 40.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.2< / td > < td class = "benchmarkresult" > 26.9< / td > < td class = "benchmarkresult" > 83.2< / td > < td class = "benchmarkresult" > 90.1< / td > < td class = "benchmarkresult" > 43.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.7< / td > < td class = "benchmarkresult" > 24.8< / td > < td class = "benchmarkresult" > 86.7< / td > < td class = "benchmarkresult" > 88.2< / td > < td class = "benchmarkresult" > 53.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 29.2< / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 87.1< / td > < td class = "benchmarkresult" > 89.4< / td > < td class = "benchmarkresult" > 50.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 45.3< / td > < td class = "benchmarkresult" > 46.7< / td > < td class = "benchmarkresult" > 98.2< / td > < td class = "benchmarkresult" > 95.2< / td > < td class = "benchmarkresult" > 58.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 131< / td > < td class = "benchmarkresult" > 134< / td > < td class = "benchmarkresult" > 83.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > std::string copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Чем длиннее строка, тем дольше создаётся копия.
2026-02-03 07:38:21 +00:00
The longer the string, the longer it takes to create a copy.< / span > < / span > < / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 155< / td > < td class = "benchmarkresult" > 178< / td > < td class = "benchmarkresult" > 184< / td > < td class = "benchmarkresult" > 126< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь stringa инициализируется не литералом,
2026-01-21 11:59:17 +00:00
а значит, должна сама хранить символы.
Here, stringa is not initialized with a literal,
2026-02-03 07:38:21 +00:00
meaning it must store characters itself.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.40< / td > < td class = "benchmarkresult" > 4.01< / td > < td class = "benchmarkresult" > 2.57< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Под WASM SSO у stringa составляет 15 символов. Кроме того,
2026-01-21 11:59:17 +00:00
собиралось без поддержки потоков, поэтому атомарный
инкремент заменён на обычный, судя по времени.
Under WASM, stringa has a 15-character SSO. Furthermore,
it was built without thread support, so the atomic
2026-02-03 07:38:21 +00:00
increment was replaced with a regular one, judging by the time.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.11< / td > < td class = "benchmarkresult" > 1.14< / td > < td class = "benchmarkresult" > 1.38< / td > < td class = "benchmarkresult" > 3.99< / td > < td class = "benchmarkresult" > 4.88< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > SSO в stringa до 23 символов, и даже 23
2026-01-21 11:59:17 +00:00
копируются быстрее, чем 15 в std::string.
SSO in stringa is up to 23 characters, and even 23
2026-02-03 07:38:21 +00:00
copies faster than 15 in std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 1.10< / td > < td class = "benchmarkresult" > 1.12< / td > < td class = "benchmarkresult" > 1.31< / td > < td class = "benchmarkresult" > 4.11< / td > < td class = "benchmarkresult" > 4.85< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Всё, не влезаем в SSO, а значит, используем shared буфер.
2026-01-21 11:59:17 +00:00
Добавляется время на атомарный инкремент счётчика.
That's it, we're not using SSO, so we're using a shared buffer.
2026-02-03 07:38:21 +00:00
Time is added for the atomic counter increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.88< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +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.97< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.8< / td > < td class = "benchmarkresult" > 4.98< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.6< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 15.9< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.88< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.1< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.84< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.4< / td > < td class = "benchmarkresult" > 4.82< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.4< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.85< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 16.0< / td > < td class = "benchmarkresult" > 18.3< / td > < td class = "benchmarkresult" > 4.85< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > stringa copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И как видно, кроме инкремента нет накладных расходов,
2026-01-21 11:59:17 +00:00
время копирования не зависит от длины строки.
And as you can see, there are no overhead costs other than the
2026-02-03 07:38:21 +00:00
increment; copying time does not depend on the string length.< / span > < / span > < / td > < td class = "benchmarkresult" > 16.3< / td > < td class = "benchmarkresult" > 16.2< / td > < td class = "benchmarkresult" > 15.8< / td > < td class = "benchmarkresult" > 19.6< / td > < td class = "benchmarkresult" > 4.80< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > lstringa< 16 > использует SSO до 23 символов.
2026-01-21 11:59:17 +00:00
А в WASM 32-битная архитектура, SSO до 19 символов.
lstringa< 16 > uses SSO up to 23 characters.
2026-02-03 07:38:21 +00:00
WASM has a 32-bit architecture, so SSO is up to 19 characters.< / span > < / span > < / td > < td class = "benchmarkresult" > 4.19< / td > < td class = "benchmarkresult" > 4.48< / td > < td class = "benchmarkresult" > 4.58< / td > < td class = "benchmarkresult" > 7.23< / td > < td class = "benchmarkresult" > 14.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.23< / td > < td class = "benchmarkresult" > 4.40< / td > < td class = "benchmarkresult" > 4.38< / td > < td class = "benchmarkresult" > 7.89< / td > < td class = "benchmarkresult" > 14.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.11< / td > < td class = "benchmarkresult" > 4.56< / td > < td class = "benchmarkresult" > 4.49< / td > < td class = "benchmarkresult" > 7.64< / td > < td class = "benchmarkresult" > 29.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > И после начинает вести себя при копировании, как std::string.
2026-02-03 07:38:21 +00:00
And then it starts to behave like std::string when copied.< / span > < / span > < / td > < td class = "benchmarkresult" > 23.4< / td > < td class = "benchmarkresult" > 23.7< / td > < td class = "benchmarkresult" > 75.0< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 29.6< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.2< / td > < td class = "benchmarkresult" > 23.4< / td > < td class = "benchmarkresult" > 77.2< / td > < td class = "benchmarkresult" > 87.1< / td > < td class = "benchmarkresult" > 32.2< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.4< / td > < td class = "benchmarkresult" > 25.3< / td > < td class = "benchmarkresult" > 77.8< / td > < td class = "benchmarkresult" > 83.7< / td > < td class = "benchmarkresult" > 34.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 24.4< / td > < td class = "benchmarkresult" > 26.6< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 84.1< / td > < td class = "benchmarkresult" > 34.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 26.2< / td > < td class = "benchmarkresult" > 28.2< / td > < td class = "benchmarkresult" > 84.3< / td > < td class = "benchmarkresult" > 85.9< / td > < td class = "benchmarkresult" > 48.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 28.9< / td > < td class = "benchmarkresult" > 31.9< / td > < td class = "benchmarkresult" > 83.5< / td > < td class = "benchmarkresult" > 87.4< / td > < td class = "benchmarkresult" > 47.2< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 93.7< / td > < td class = "benchmarkresult" > 96.4< / td > < td class = "benchmarkresult" > 93.8< / td > < td class = "benchmarkresult" > 96.4< / td > < td class = "benchmarkresult" > 53.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 131< / td > < td class = "benchmarkresult" > 79.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 16> copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 121< / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 188< / td > < td class = "benchmarkresult" > 193< / td > < td class = "benchmarkresult" > 123< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/15< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.49< / td > < td class = "benchmarkresult" > 5.38< / td > < td class = "benchmarkresult" > 4.86< / td > < td class = "benchmarkresult" > 8.05< / td > < td class = "benchmarkresult" > 14.8< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/16< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.61< / td > < td class = "benchmarkresult" > 5.51< / td > < td class = "benchmarkresult" > 4.96< / td > < td class = "benchmarkresult" > 8.06< / td > < td class = "benchmarkresult" > 15.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/23< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.75< / td > < td class = "benchmarkresult" > 5.67< / td > < td class = "benchmarkresult" > 4.86< / td > < td class = "benchmarkresult" > 8.24< / td > < td class = "benchmarkresult" > 15.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/24< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5.41< / td > < td class = "benchmarkresult" > 5.45< / td > < td class = "benchmarkresult" > 4.99< / td > < td class = "benchmarkresult" > 8.02< / td > < td class = "benchmarkresult" > 15.2< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/32< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 4.77< / td > < td class = "benchmarkresult" > 5.07< / td > < td class = "benchmarkresult" > 8.65< / td > < td class = "benchmarkresult" > 10.9< / td > < td class = "benchmarkresult" > 18.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/64< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.39< / td > < td class = "benchmarkresult" > 6.54< / td > < td class = "benchmarkresult" > 7.99< / td > < td class = "benchmarkresult" > 10.8< / td > < td class = "benchmarkresult" > 18.2< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/128< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 6.25< / td > < td class = "benchmarkresult" > 7.26< / td > < td class = "benchmarkresult" > 8.09< / td > < td class = "benchmarkresult" > 11.4< / td > < td class = "benchmarkresult" > 19.2< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/256< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 8.31< / td > < td class = "benchmarkresult" > 8.60< / td > < td class = "benchmarkresult" > 9.30< / td > < td class = "benchmarkresult" > 12.4< / td > < td class = "benchmarkresult" > 19.6< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/512< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Даже 512 символов копируются быстрее, чем
2026-01-21 11:59:17 +00:00
одна аллокация или атомарный инкремент.
Even 512 characters are copied faster than a single
2026-02-03 07:38:21 +00:00
allocation or atomic increment.< / span > < / span > < / td > < td class = "benchmarkresult" > 10.1< / td > < td class = "benchmarkresult" > 11.5< / td > < td class = "benchmarkresult" > 11.0< / td > < td class = "benchmarkresult" > 14.2< / td > < td class = "benchmarkresult" > 22.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/1024< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А дальше уже как у всех.
2026-02-03 07:38:21 +00:00
And then it's like everyone else.< / span > < / span > < / td > < td class = "benchmarkresult" > 94.6< / td > < td class = "benchmarkresult" > 108< / td > < td class = "benchmarkresult" > 99.1< / td > < td class = "benchmarkresult" > 99.5< / td > < td class = "benchmarkresult" > 57.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/2048< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 106< / td > < td class = "benchmarkresult" > 110< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 132< / td > < td class = "benchmarkresult" > 79.9< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L565" > lstringa< 512> copy{str_with_len_N};/4096< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void CopyDynString(benchmark::State& state) {
T x(state.range(0), ' a' );
for (auto _: state) {
T copy{x};
benchmark::DoNotOptimize(copy);
benchmark::DoNotOptimize(x);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 127< / td > < td class = "benchmarkresult" > 135< / td > < td class = "benchmarkresult" > 184< / td > < td class = "benchmarkresult" > 194< / td > < td class = "benchmarkresult" > 123< / td > < / tr >
< / 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 4 ' , t e s t s : [
{name:'std::string copy{str_with_len_N};/15',data:[5.61,5.53,1.84,5.04,35.7]},
{name:'std::string copy{str_with_len_N};/16',data:[23.0,23.7,79.1,81.5,35.9]},
{name:'std::string copy{str_with_len_N};/23',data:[23.0,23.4,78.4,81.8,36.3]},
{name:'std::string copy{str_with_len_N};/24',data:[22.9,23.2,78.1,82.5,37.4]},
{name:'std::string copy{str_with_len_N};/32',data:[22.4,23.4,79.2,86.1,41.8]},
{name:'std::string copy{str_with_len_N};/64',data:[23.1,22.4,80.3,87.9,40.9]},
{name:'std::string copy{str_with_len_N};/128',data:[24.2,26.9,83.2,90.1,43.9]},
{name:'std::string copy{str_with_len_N};/256',data:[24.7,24.8,86.7,88.2,53.7]},
{name:'std::string copy{str_with_len_N};/512',data:[29.2,28.5,87.1,89.4,50.9]},
{name:'std::string copy{str_with_len_N};/1024',data:[45.3,46.7,98.2,95.2,58.1]},
{name:'std::string copy{str_with_len_N};/2048',data:[123,127,131,134,83.5]},
{name:'std::string copy{str_with_len_N};/4096',data:[153,155,178,184,126]},
{name:'stringa copy{str_with_len_N};/15',data:[1.10,1.14,1.40,4.01,2.57]},
{name:'stringa copy{str_with_len_N};/16',data:[1.11,1.14,1.38,3.99,4.88]},
{name:'stringa copy{str_with_len_N};/23',data:[1.10,1.12,1.31,4.11,4.85]},
{name:'stringa copy{str_with_len_N};/24',data:[16.2,16.1,15.8,18.4,4.88]},
{name:'stringa copy{str_with_len_N};/32',data:[16.3,16.0,15.9,18.6,4.97]},
{name:'stringa copy{str_with_len_N};/64',data:[16.4,16.1,16.0,18.8,4.98]},
{name:'stringa copy{str_with_len_N};/128',data:[16.6,16.2,15.9,18.4,4.88]},
{name:'stringa copy{str_with_len_N};/256',data:[16.3,16.1,15.8,18.3,4.84]},
{name:'stringa copy{str_with_len_N};/512',data:[16.3,16.3,15.8,18.4,4.82]},
{name:'stringa copy{str_with_len_N};/1024',data:[16.4,16.0,15.8,18.3,4.85]},
{name:'stringa copy{str_with_len_N};/2048',data:[16.3,16.0,16.0,18.3,4.85]},
{name:'stringa copy{str_with_len_N};/4096',data:[16.3,16.2,15.8,19.6,4.80]},
{name:'lstringa< 16 > copy{str_with_len_N};/15',data:[4.19,4.48,4.58,7.23,14.3]},
{name:'lstringa< 16 > copy{str_with_len_N};/16',data:[4.23,4.40,4.38,7.89,14.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/23',data:[4.11,4.56,4.49,7.64,29.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/24',data:[23.4,23.7,75.0,83.5,29.6]},
{name:'lstringa< 16 > copy{str_with_len_N};/32',data:[23.2,23.4,77.2,87.1,32.2]},
{name:'lstringa< 16 > copy{str_with_len_N};/64',data:[24.4,25.3,77.8,83.7,34.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/128',data:[24.4,26.6,83.5,84.1,34.3]},
{name:'lstringa< 16 > copy{str_with_len_N};/256',data:[26.2,28.2,84.3,85.9,48.1]},
{name:'lstringa< 16 > copy{str_with_len_N};/512',data:[28.9,31.9,83.5,87.4,47.2]},
{name:'lstringa< 16 > copy{str_with_len_N};/1024',data:[93.7,96.4,93.8,96.4,53.7]},
{name:'lstringa< 16 > copy{str_with_len_N};/2048',data:[107,107,132,131,79.5]},
{name:'lstringa< 16 > copy{str_with_len_N};/4096',data:[121,126,188,193,123]},
{name:'lstringa< 512 > copy{str_with_len_N};/15',data:[4.49,5.38,4.86,8.05,14.8]},
{name:'lstringa< 512 > copy{str_with_len_N};/16',data:[4.61,5.51,4.96,8.06,15.7]},
{name:'lstringa< 512 > copy{str_with_len_N};/23',data:[4.75,5.67,4.86,8.24,15.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/24',data:[5.41,5.45,4.99,8.02,15.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/32',data:[4.77,5.07,8.65,10.9,18.3]},
{name:'lstringa< 512 > copy{str_with_len_N};/64',data:[6.39,6.54,7.99,10.8,18.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/128',data:[6.25,7.26,8.09,11.4,19.2]},
{name:'lstringa< 512 > copy{str_with_len_N};/256',data:[8.31,8.60,9.30,12.4,19.6]},
{name:'lstringa< 512 > copy{str_with_len_N};/512',data:[10.1,11.5,11.0,14.2,22.9]},
{name:'lstringa< 512 > copy{str_with_len_N};/1024',data:[94.6,108,99.1,99.5,57.1]},
{name:'lstringa< 512 > copy{str_with_len_N};/2048',data:[106,110,132,132,79.9]},
{name:'lstringa< 512 > copy{str_with_len_N};/4096',data:[127,135,184,194,123]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs15" > < h4 > < a id = "bs94756718925776995960" href = "#bs94756718925776995960" > #< / a > Convert to int ' 1234567' < / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L580" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 10);< / a > < span class = "tooltiptext code" > void ToIntStr10(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 10);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr для конвертации в число достаточно куска строки,
нет нужды в null терминированности. Ближайший аналог такого
поведения "std::from_chars", но он к сожалению очень ограничен
по возможностям. Здесь я попытался произвести тесты, близкие по
2026-01-21 11:59:17 +00:00
логике к работе std::from_chars
In simstr, a string fragment is sufficient for conversion to a number;
there's no need for null termination. The closest analog to this behavior
is "std::from_chars," but unfortunately, it is very limited in its capabilities.
2026-02-03 07:38:21 +00:00
Here, I attempted to run tests that are similar in logic to std::from_chars.< / span > < / span > < / td > < td class = "benchmarkresult" > 27.1< / td > < td class = "benchmarkresult" > 27.9< / td > < td class = "benchmarkresult" > 30.7< / td > < td class = "benchmarkresult" > 32.1< / td > < td class = "benchmarkresult" > 71.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L619" > std::string_view s = " 123456789" ; std::from_chars(s.data(), s.data() + s.size(), res, 10);< / a > < span class = "tooltiptext code" > void ToIntFromChars10(benchmark::State& state, const std::string_view& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = 0;
std::from_chars(s.data(), s.data() + s.size(), res, 10);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > from_chars требует точного указания основания счисления,
2026-01-21 11:59:17 +00:00
не допускает знаков плюс, пробелов, префиксов 0x и т.п.
from_chars requires an exact radix specification and does not allow plus
2026-02-03 07:38:21 +00:00
signs, spaces, 0x prefixes, etc.< / span > < / span > < / td > < td class = "benchmarkresult" > 15.3< / td > < td class = "benchmarkresult" > 12.5< / td > < td class = "benchmarkresult" > 13.7< / td > < td class = "benchmarkresult" > 13.7< / td > < td class = "benchmarkresult" > 27.1< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L647" > stringa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Здесь для to_int заданы такие же ограничения - проверять переполнение,
2026-01-21 11:59:17 +00:00
десятичная система, без лидирующих пробелов и знака плюс
Here, to_int has the same restrictions: check for overflow,
2026-02-03 07:38:21 +00:00
decimal system, no leading spaces, and no plus sign.< / span > < / span > < / td > < td class = "benchmarkresult" > 12.9< / td > < td class = "benchmarkresult" > 8.32< / td > < td class = "benchmarkresult" > 14.4< / td > < td class = "benchmarkresult" > 14.6< / td > < td class = "benchmarkresult" > 18.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L647" > ssa s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.6< / td > < td class = "benchmarkresult" > 7.92< / td > < td class = "benchmarkresult" > 13.7< / td > < td class = "benchmarkresult" > 15.1< / td > < td class = "benchmarkresult" > 17.0< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L647" > lstringa< 20> s = " 123456789" ; int res = s.to_int< int, true, 10, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr10(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 10, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.4< / td > < td class = "benchmarkresult" > 8.46< / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 15.1< / td > < td class = "benchmarkresult" > 16.9< / td > < / tr >
< / 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 5 ' , t e s t s : [
{name:'std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);',data:[27.1,27.9,30.7,32.1,71.7]},
{name:'std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);',data:[15.3,12.5,13.7,13.7,27.1]},
{name:'stringa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[12.9,8.32,14.4,14.6,18.7]},
{name:'ssa s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[12.6,7.92,13.7,15.1,17.0]},
{name:'lstringa< 20 > s = "123456789"; int res = s.to_int< int , true , 10 , false > ',data:[12.4,8.46,13.1,15.1,16.9]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs16" > < h4 > < a id = "bs182426078870126042750" href = "#bs182426078870126042750" > #< / a > Convert to unsigned ' abcDef' < / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L593" > std::string s = " abcDef" ; int res = std::strtol(s.c_str(), 0, 16);< / a > < span class = "tooltiptext code" > void ToIntStr16(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 16);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Всё то же, только для 16р ично й системы
2026-02-03 07:38:21 +00:00
Everything is the same, only for the hexadecimal system< / span > < / span > < / td > < td class = "benchmarkresult" > 23.8< / td > < td class = "benchmarkresult" > 25.5< / td > < td class = "benchmarkresult" > 33.5< / td > < td class = "benchmarkresult" > 35.5< / td > < td class = "benchmarkresult" > 54.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L633" > std::string_view s = " abcDef" ; std::from_chars(s.data(), s.data() + s.size(), res, 16);< / a > < span class = "tooltiptext code" > void ToIntFromChars16(benchmark::State& state, const std::string_view& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = 0;
std::from_chars(s.data(), s.data() + s.size(), res, 16);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 9.64< / td > < td class = "benchmarkresult" > 10.3< / td > < td class = "benchmarkresult" > 8.10< / td > < td class = "benchmarkresult" > 13.2< / td > < td class = "benchmarkresult" > 28.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L662" > stringa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 13.5< / td > < td class = "benchmarkresult" > 8.23< / td > < td class = "benchmarkresult" > 12.0< / td > < td class = "benchmarkresult" > 14.0< / td > < td class = "benchmarkresult" > 17.7< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L662" > ssa s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 13.3< / td > < td class = "benchmarkresult" > 7.99< / td > < td class = "benchmarkresult" > 12.0< / td > < td class = "benchmarkresult" > 13.8< / td > < td class = "benchmarkresult" > 16.0< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L662" > lstringa< 20> s = " abcDef" ; int res = s.to_int< int, true, 16, false>< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr16(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int, true, 16, false, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 12.3< / td > < td class = "benchmarkresult" > 8.36< / td > < td class = "benchmarkresult" > 11.7< / td > < td class = "benchmarkresult" > 13.1< / td > < td class = "benchmarkresult" > 16.0< / td > < / tr >
< / 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 6 ' , t e s t s : [
{name:'std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);',data:[23.8,25.5,33.5,35.5,54.3]},
{name:'std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);',data:[9.64,10.3,8.10,13.2,28.7]},
{name:'stringa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[13.5,8.23,12.0,14.0,17.7]},
{name:'ssa s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[13.3,7.99,12.0,13.8,16.0]},
{name:'lstringa< 20 > s = "abcDef"; int res = s.to_int< int , true , 16 , false > ',data:[12.3,8.36,11.7,13.1,16.0]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs17" > < h4 > < a id = "bs52606100125109966680" href = "#bs52606100125109966680" > #< / a > Convert to int ' 1234567' < / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L606" > std::string s = " 123456789" ; int res = std::strtol(s.c_str(), 0, 0);< / a > < span class = "tooltiptext code" > void ToIntStr0(benchmark::State& state, const std::string& s, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
int res = std::strtol(s.c_str(), nullptr, 0);
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А здесь уже парсинг произвольного числа.
2026-02-03 07:38:21 +00:00
And here we have parsing of an arbitrary number.< / span > < / span > < / td > < td class = "benchmarkresult" > 28.5< / td > < td class = "benchmarkresult" > 28.8< / td > < td class = "benchmarkresult" > 43.5< / td > < td class = "benchmarkresult" > 44.6< / td > < td class = "benchmarkresult" > 81.3< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L677" > stringa s = " 123456789" ; int res = s.to_int< int>; // Check overflow< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void ToIntSimStr0(benchmark::State& state, T t, int c) {
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t. template to_int< int>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 19.1< / td > < td class = "benchmarkresult" > 15.1< / td > < td class = "benchmarkresult" > 17.7< / td > < td class = "benchmarkresult" > 19.0< / td > < td class = "benchmarkresult" > 24.5< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L692" > ssa s = " 123456789" ; int res = s.to_int< int, false>; // No check overflow< / a > < span class = "tooltiptext code" > void ToIntNoOverflow(benchmark::State& state, ssa t, int c) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
2025-11-26 19:15:50 +00:00
int res = t.to_int< int, false>().value;
2025-04-05 14:21:11 +00:00
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 15.4< / td > < td class = "benchmarkresult" > 10.6< / td > < td class = "benchmarkresult" > 16.5< / td > < td class = "benchmarkresult" > 17.5< / td > < td class = "benchmarkresult" > 23.2< / td > < / tr >
< / 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 7 ' , t e s t s : [
{name:'std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);',data:[28.5,28.8,43.5,44.6,81.3]},
{name:'stringa s = " 123456789"; int res = s.to_int< int > ; // Check overflow',data:[19.1,15.1,17.7,19.0,24.5]},
{name:'ssa s = " 123456789"; int res = s.to_int< int , false > ; // No check overflow',data:[15.4,10.6,16.5,17.5,23.2]}
2025-11-26 19:15:50 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs18" > < h4 > < a id = "bs182348477702821075660" href = "#bs182348477702821075660" > #< / a > Convert to double ' 1234.567e10' < / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L723" > std::string s = " 1234.567e10" ; double res = std::strtod(s.c_str(), nullptr);< / a > < span class = "tooltiptext code" > void ToDoubleStr(benchmark::State& state, const std::string& s, double c) {
2025-11-26 19:15:50 +00:00
for (auto _: state) {
char* ptr = nullptr;
double res = std::strtod(s.c_str(), & ptr);
if (ptr == s.c_str()) {
state.SkipWithError(" not equal" );
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 66.3< / td > < td class = "benchmarkresult" > 65.1< / td > < td class = "benchmarkresult" > 100< / td > < td class = "benchmarkresult" > 99.7< / td > < td class = "benchmarkresult" > 197< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L740" > std::string_view s = " 1234.567e10" ; std::from_chars(s.data(), s.data() + s.size(), res);< / a > < span class = "tooltiptext code" > void ToDoubleFromChars(benchmark::State& state, const std::string_view& s, double c) {
2025-11-26 19:15:50 +00:00
for (auto _: state) {
double res = 0;
if (std::from_chars(s.data(), s.data() + s.size(), res).ec != std::errc{}) {
state.SkipWithError(" not equal" );
}
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23.9< / td > < td class = "benchmarkresult" > 23.8< / td > < td class = "benchmarkresult" > 59.3< / td > < td class = "benchmarkresult" > 80.0< / td > < td class = "benchmarkresult" > 107< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L756" > ssa s = " 1234.567e10" ; double res = *s.to_double()< / a > < span class = "tooltiptext code" > template< typename T>
2025-11-26 19:15:50 +00:00
void ToDoubleSimStr(benchmark::State& state, T t, double c) {
for (auto _: state) {
auto r = t.template to_double< false>();
if (!r) {
state.SkipWithError(" not equal" );
}
double res = *r;
#ifdef CHECK_RESULT
if (res != c) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(res);
benchmark::DoNotOptimize(t);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 25.8< / td > < td class = "benchmarkresult" > 24.7< / td > < td class = "benchmarkresult" > 34.9< / td > < td class = "benchmarkresult" > 36.1< / td > < td class = "benchmarkresult" > 42.3< / td > < / tr >
< / 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 8 ' , t e s t s : [
{name:'std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);',data:[66.3,65.1,100,99.7,197]},
{name:'std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);',data:[23.9,23.8,59.3,80.0,107]},
{name:'ssa s = "1234.567e10"; double res = *s.to_double()',data:[25.8,24.7,34.9,36.1,42.3]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs19" > < h4 > < a id = "bs96505608161678391610" href = "#bs96505608161678391610" > #< / a > Append const literal of 16 bytes 64 times, 1024 total length< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L780" > std::stringstream str; ... str < < " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStreamConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
std::stringstream str;
for (size_t c = 0; c < 64; c++) {
str < < TEXT_16;
}
result = str.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(str);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1343< / td > < td class = "benchmarkresult" > 1335< / td > < td class = "benchmarkresult" > 4829< / td > < td class = "benchmarkresult" > 5533< / td > < td class = "benchmarkresult" > 4356< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L799" > std::string str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStdStringConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 400< / td > < td class = "benchmarkresult" > 380< / td > < td class = "benchmarkresult" > 1079< / td > < td class = "benchmarkresult" > 1309< / td > < td class = "benchmarkresult" > 595< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L815" > lstringa< 8> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 384< / td > < td class = "benchmarkresult" > 394< / td > < td class = "benchmarkresult" > 747< / td > < td class = "benchmarkresult" > 947< / td > < td class = "benchmarkresult" > 741< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L815" > lstringa< 128> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Чем больше внутренний буфер, тем меньше раз требуется
2026-01-21 11:59:17 +00:00
аллокация, тем быстрее результат.
The larger the internal buffer, the fewer allocations are
2026-02-03 07:38:21 +00:00
required, and the faster the result.< / span > < / span > < / td > < td class = "benchmarkresult" > 282< / td > < td class = "benchmarkresult" > 272< / td > < td class = "benchmarkresult" > 391< / td > < td class = "benchmarkresult" > 523< / td > < td class = "benchmarkresult" > 571< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L815" > lstringa< 512> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 255< / td > < td class = "benchmarkresult" > 250< / td > < td class = "benchmarkresult" > 238< / td > < td class = "benchmarkresult" > 348< / td > < td class = "benchmarkresult" > 464< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L815" > lstringa< 1024> str; ... str += " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringConstLiteral(benchmark::State& state) {
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 64; c++) {
result += TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 140< / td > < td class = "benchmarkresult" > 156< / td > < td class = "benchmarkresult" > 234< / td > < td class = "benchmarkresult" > 396< / td > < / tr >
< / 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 9 ' , t e s t s : [
{name:'std::stringstream str; ... str < < "abbaabbaabbaabba";',data:[1343,1335,4829,5533,4356]},
{name:'std::string str; ... str += "abbaabbaabbaabba";',data:[400,380,1079,1309,595]},
{name:'lstringa< 8 > str; ... str += "abbaabbaabbaabba";',data:[384,394,747,947,741]},
{name:'lstringa< 128 > str; ... str += "abbaabbaabbaabba";',data:[282,272,391,523,571]},
{name:'lstringa< 512 > str; ... str += "abbaabbaabbaabba";',data:[255,250,238,348,464]},
{name:'lstringa< 1024 > str; ... str += "abbaabbaabbaabba";',data:[154,140,156,234,396]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs20" > < h4 > < a id = "bs36931044816721597850" href = "#bs36931044816721597850" > #< / a > Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L840" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStreamStrConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 32; c++) {
s < < s1 < < TEXT_16;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1440< / td > < td class = "benchmarkresult" > 1363< / td > < td class = "benchmarkresult" > 4512< / td > < td class = "benchmarkresult" > 5823< / td > < td class = "benchmarkresult" > 4443< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L860" > std::string str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > void AppendStdStrStrConstLiteral(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string p1 = TEXT_16;
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1221< / td > < td class = "benchmarkresult" > 1255< / td > < td class = "benchmarkresult" > 3730< / td > < td class = "benchmarkresult" > 4097< / td > < td class = "benchmarkresult" > 1968< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L878" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 444< / td > < td class = "benchmarkresult" > 484< / td > < td class = "benchmarkresult" > 702< / td > < td class = "benchmarkresult" > 880< / td > < td class = "benchmarkresult" > 921< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L878" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 366< / td > < td class = "benchmarkresult" > 459< / td > < td class = "benchmarkresult" > 448< / td > < td class = "benchmarkresult" > 561< / td > < td class = "benchmarkresult" > 694< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L878" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 297< / td > < td class = "benchmarkresult" > 354< / td > < td class = "benchmarkresult" > 298< / td > < td class = "benchmarkresult" > 380< / td > < td class = "benchmarkresult" > 656< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L878" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteral(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 201< / td > < td class = "benchmarkresult" > 245< / td > < td class = "benchmarkresult" > 207< / td > < td class = "benchmarkresult" > 277< / td > < td class = "benchmarkresult" > 543< / td > < / tr >
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' A p p e n d s t r i n g o f 1 6 b y t e s a n d c o n s t l i t e r a l o f 1 6 b y t e s 3 2 t i m e s , 1 0 2 4 t o t a l l e n g t h ' ] = { i d : ' b s 2 0 ' , t e s t s : [
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; ' , data: [ 1440 , 1363 , 4512 , 5823 , 4443 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba";',data:[1221,1255,3730,4097,1968]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba";',data:[444,484,702,880,921]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba";',data:[366,459,448,561,694]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba";',data:[297,354,298,380,656]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba";',data:[201,245,207,277,543]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs21" > < h4 > < a id = "bs8293767858383349360" href = "#bs8293767858383349360" > #< / a > Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L906" > std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > void AppendStreamStrConstLiteralBig(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 2048; c++) {
s < < s1 < < TEXT_16;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 77169< / td > < td class = "benchmarkresult" > 73412< / td > < td class = "benchmarkresult" > 217555< / td > < td class = "benchmarkresult" > 307647< / td > < td class = "benchmarkresult" > 223755< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L926" > std::string str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > void AppendStdStrStrConstLiteralBig(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string p1 = TEXT_16;
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.size() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 73735< / td > < td class = "benchmarkresult" > 71780< / td > < td class = "benchmarkresult" > 187292< / td > < td class = "benchmarkresult" > 186310< / td > < td class = "benchmarkresult" > 106717< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L944" > lstringa< 8> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 23209< / td > < td class = "benchmarkresult" > 21248< / td > < td class = "benchmarkresult" > 19125< / td > < td class = "benchmarkresult" > 24024< / td > < td class = "benchmarkresult" > 40706< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L944" > lstringa< 128> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 18060< / td > < td class = "benchmarkresult" > 17315< / td > < td class = "benchmarkresult" > 16790< / td > < td class = "benchmarkresult" > 22287< / td > < td class = "benchmarkresult" > 39893< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L944" > lstringa< 512> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 19949< / td > < td class = "benchmarkresult" > 17550< / td > < td class = "benchmarkresult" > 16182< / td > < td class = "benchmarkresult" > 22240< / td > < td class = "benchmarkresult" > 39281< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L944" > lstringa< 1024> str; ... str += str_var + " abbaabbaabbaabba" ; 2048 times< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
stringa p1 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 2048; c++) {
result += p1 + TEXT_16;
}
#ifdef CHECK_RESULT
if (result.length() != 1024 * 64) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(p1);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 20464< / td > < td class = "benchmarkresult" > 17182< / td > < td class = "benchmarkresult" > 16072< / td > < td class = "benchmarkresult" > 21810< / td > < td class = "benchmarkresult" > 39556< / td > < / tr >
< / 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 1 ' , t e s t s : [
{name:'std::stringstream str; ... str < < str_var < < " abbaabbaabbaabba " ; 2048 times ' , data: [ 77169 , 73412 , 217555 , 307647 , 223755 ] } ,
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[73735,71780,187292,186310,106717]},
{name:'lstringa< 8 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[23209,21248,19125,24024,40706]},
{name:'lstringa< 128 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[18060,17315,16790,22287,39893]},
{name:'lstringa< 512 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[19949,17550,16182,22240,39281]},
{name:'lstringa< 1024 > str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[20464,17182,16072,21810,39556]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs22" > < h4 > < a id = "bs66949588770596833730" href = "#bs66949588770596833730" > #< / a > Append 2 string of 16 bytes 32 times, 1024 total length< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L971" > std::stringstream str; ... str < < str_var1 < < str_var2;< / a > < span class = "tooltiptext code" > void AppendStream2String(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
std::string s2 = TEXT_16;
for (auto _: state) {
std::string result;
std::stringstream s;
for (size_t c = 0; c < 32; c++) {
s < < s1 < < s2;
}
result = s.str();
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1527< / td > < td class = "benchmarkresult" > 1538< / td > < td class = "benchmarkresult" > 4365< / td > < td class = "benchmarkresult" > 5193< / td > < td class = "benchmarkresult" > 4753< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L993" > std::string str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > void AppendStdStr2String(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string s1 = TEXT_16;
std::string s2 = TEXT_16;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.size() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1467< / td > < td class = "benchmarkresult" > 1325< / td > < td class = "benchmarkresult" > 3878< / td > < td class = "benchmarkresult" > 4025< / td > < td class = "benchmarkresult" > 2557< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1014" > lstringa< 16> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 532< / td > < td class = "benchmarkresult" > 567< / td > < td class = "benchmarkresult" > 858< / td > < td class = "benchmarkresult" > 909< / td > < td class = "benchmarkresult" > 1248< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1014" > lstringa< 128> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 466< / td > < td class = "benchmarkresult" > 479< / td > < td class = "benchmarkresult" > 598< / td > < td class = "benchmarkresult" > 645< / td > < td class = "benchmarkresult" > 1085< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1014" > lstringa< 512> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 413< / td > < td class = "benchmarkresult" > 412< / td > < td class = "benchmarkresult" > 388< / td > < td class = "benchmarkresult" > 457< / td > < td class = "benchmarkresult" > 934< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1014" > lstringa< 1024> str; ... str += str_var1 + str_var2;< / a > < span class = "tooltiptext code" > template< unsigned N>
2025-04-05 14:21:11 +00:00
void AppendLstring2String(benchmark::State& state) {
stra s1 = TEXT_16;
stra s2 = TEXT_16;
for (auto _: state) {
lstringa< N> result;
for (size_t c = 0; c < 32; c++) {
result += s1 + s2;
}
#ifdef CHECK_RESULT
if (result.length() != 1024) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(s1);
benchmark::DoNotOptimize(s2);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 314< / td > < td class = "benchmarkresult" > 315< / td > < td class = "benchmarkresult" > 284< / td > < td class = "benchmarkresult" > 358< / td > < td class = "benchmarkresult" > 850< / td > < / tr >
< / 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 2 ' , t e s t s : [
{name:'std::stringstream str; ... str < < str_var1 < < str_var2 ; ' , data: [ 1527 , 1538 , 4365 , 5193 , 4753 ] } ,
{name:'std::string str; ... str += str_var1 + str_var2;',data:[1467,1325,3878,4025,2557]},
{name:'lstringa< 16 > str; ... str += str_var1 + str_var2;',data:[532,567,858,909,1248]},
{name:'lstringa< 128 > str; ... str += str_var1 + str_var2;',data:[466,479,598,645,1085]},
{name:'lstringa< 512 > str; ... str += str_var1 + str_var2;',data:[413,412,388,457,934]},
{name:'lstringa< 1024 > str; ... str += str_var1 + str_var2;',data:[314,315,284,358,850]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs23" > < h4 > < a id = "bs130432147582115154460" href = "#bs130432147582115154460" > #< / a > Append text, number, text< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1043" > std::stringstream str; str < < " test = " < < k < < " times" ;< / a > < span class = "tooltiptext code" > void AppendStreamStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::stringstream t;
t < < " test = " < < k < < " times" ;
std::string result = t.str();
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3076< / td > < td class = "benchmarkresult" > 3323< / td > < td class = "benchmarkresult" > 10795< / td > < td class = "benchmarkresult" > 11158< / td > < td class = "benchmarkresult" > 6507< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1061" > std::string str = " test = " + std::to_string(k) + " times" ;< / a > < span class = "tooltiptext code" > void AppendStdStringStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::string result = " test = " + std::to_string(k) + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 494< / td > < td class = "benchmarkresult" > 474< / td > < td class = "benchmarkresult" > 1087< / td > < td class = "benchmarkresult" > 1231< / td > < td class = "benchmarkresult" > 1696< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1077" > char buf[100]; sprintf(buf, " test = %u times" , k); std::string str = buf;< / a > < span class = "tooltiptext code" > void AppendSprintfStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
char buf[100];
std::sprintf(buf, " test = %u times" , k);
std::string result = buf;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1421< / td > < td class = "benchmarkresult" > 1486< / td > < td class = "benchmarkresult" > 2794< / td > < td class = "benchmarkresult" > 2861< / td > < td class = "benchmarkresult" > 2885< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1095" > std::string str = std::format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > void AppendFormatStrNumStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
std::string result = std::format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1118< / td > < td class = "benchmarkresult" > 1312< / td > < td class = "benchmarkresult" > 1897< / td > < td class = "benchmarkresult" > 2540< / td > < td class = "benchmarkresult" > 2102< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1111" > lstringa< 8> str; str.format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStrF(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result;
result.format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > В simstr format с первого раза не помещается в такую строку без аллокации.
In simstr format, the first time it doesn't fit into such a
2026-02-03 07:38:21 +00:00
string without allocation.< / span > < / span > < / td > < td class = "benchmarkresult" > 1374< / td > < td class = "benchmarkresult" > 1646< / td > < td class = "benchmarkresult" > 2073< / td > < td class = "benchmarkresult" > 2756< / td > < td class = "benchmarkresult" > 3013< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1111" > lstringa< 32> str; str.format(" test = {} times" , k);< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStrF(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result;
result.format(" test = {} times" , k);
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А в такую помещается. Используйте сразу буфера подходящего размера.
2026-02-03 07:38:21 +00:00
And it fits in this one. Use buffers of the appropriate size right away.< / span > < / span > < / td > < td class = "benchmarkresult" > 974< / td > < td class = "benchmarkresult" > 1116< / td > < td class = "benchmarkresult" > 1100< / td > < td class = "benchmarkresult" > 1528< / td > < td class = "benchmarkresult" > 2433< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1129" > lstringa< 8> str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Результат не помещается в SSO, возникает аллокация.
2026-02-03 07:38:21 +00:00
The result does not fit into SSO, an allocation occurs.< / span > < / span > < / td > < td class = "benchmarkresult" > 296< / td > < td class = "benchmarkresult" > 301< / td > < td class = "benchmarkresult" > 867< / td > < td class = "benchmarkresult" > 910< / td > < td class = "benchmarkresult" > 641< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1129" > lstringa< 32> str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > А здесь и ниже - результат укладывается в SSO.
2026-01-21 11:59:17 +00:00
Ещё раз - используйте сразу буфера подходящего размера.
And here and below, the result fits within SSO.
2026-02-03 07:38:21 +00:00
Once again, use appropriately sized buffers from the start.< / span > < / span > < / td > < td class = "benchmarkresult" > 155< / td > < td class = "benchmarkresult" > 146< / td > < td class = "benchmarkresult" > 168< / td > < td class = "benchmarkresult" > 183< / td > < td class = "benchmarkresult" > 374< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1129" > stringa str = " test = " + k + " times" ;< / a > < span class = "tooltiptext code" > template< typename T>
2025-04-05 14:21:11 +00:00
void AppendSimStrStrNumStr(benchmark::State& state) {
for (auto _: state) {
for (unsigned k = 1; k < = 1' 000' 000' 000; k *= 10) {
T result = " test = " _ss + k + " times" ;
#ifdef CHECK_RESULT
if (!result.starts_with(" test = " ) || !result.ends_with(" times" )) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(k);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Под WASM размер SSO 15 символов, что явно не хватает для размещения
2026-01-21 11:59:17 +00:00
результата, отсюда и такое время.
Under WASM, the SSO size is 15 characters, which is clearly not
2026-02-03 07:38:21 +00:00
enough to accommodate the result, hence the long time.< / span > < / span > < / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 163< / td > < td class = "benchmarkresult" > 152< / td > < td class = "benchmarkresult" > 238< / td > < td class = "benchmarkresult" > 561< / td > < / tr >
< / 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 3 ' , t e s t s : [
{name:'std::stringstream str; str < < "test = " < < k < < " times " ; ' , data: [ 3076 , 3323 , 10795 , 11158 , 6507 ] } ,
{name:'std::string str = "test = " + std::to_string(k) + " times";',data:[494,474,1087,1231,1696]},
{name:'char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;',data:[1421,1486,2794,2861,2885]},
{name:'std::string str = std::format("test = {} times", k);',data:[1118,1312,1897,2540,2102]},
{name:'lstringa< 8 > str; str.format("test = {} times", k);',data:[1374,1646,2073,2756,3013]},
{name:'lstringa< 32 > str; str.format("test = {} times", k);',data:[974,1116,1100,1528,2433]},
{name:'lstringa< 8 > str = "test = " + k + " times";',data:[296,301,867,910,641]},
{name:'lstringa< 32 > str = "test = " + k + " times";',data:[155,146,168,183,374]},
{name:'stringa str = "test = " + k + " times";',data:[153,163,152,238,561]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs24" > < h4 > < a id = "bs7106975351756760120" href = "#bs7106975351756760120" > #< / a > Split text and convert to int< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1159" > std::string::find + substr + std::strtol< / a > < span class = "tooltiptext code" > void SplitConvertIntStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
for (size_t start = 0; start < numbers.length(); ) {
int delim = numbers.find(" -!-" , start);
if (delim == std::string::npos) {
delim = numbers.size();
}
std::string part = numbers.substr(start, delim - start);
total += std::strtol(part.c_str(), nullptr, 0);
start = delim + 3;
}
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 281< / td > < td class = "benchmarkresult" > 278< / td > < td class = "benchmarkresult" > 550< / td > < td class = "benchmarkresult" > 542< / td > < td class = "benchmarkresult" > 643< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1183" > ssa::splitter + ssa::as_int< / a > < span class = "tooltiptext code" > void SplitConvertIntSimStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
stra numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
for (auto splitter = numbers.splitter(" -!-" ); !splitter.is_done();) {
total += splitter.next().as_int< int>();
}
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 157< / td > < td class = "benchmarkresult" > 139< / td > < td class = "benchmarkresult" > 160< / td > < td class = "benchmarkresult" > 294< / td > < td class = "benchmarkresult" > 278< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1200" > ssa::splitf + functor< / a > < span class = "tooltiptext code" > void SplitConvertIntSplitf(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
stra numbers = NUMBER_LIST;
for (auto _: state) {
int total = 0;
numbers.splitf< void>(" -!-" , [& ](ssa& part){total += part.as_int< int>();});
#ifdef CHECK_RESULT
if (total != 218) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(total);
benchmark::DoNotOptimize(numbers);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 215< / td > < td class = "benchmarkresult" > 126< / td > < td class = "benchmarkresult" > 198< / td > < td class = "benchmarkresult" > 214< / td > < td class = "benchmarkresult" > 337< / td > < / tr >
< / 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 4 ' , t e s t s : [
{name:'std::string::find + substr + std::strtol',data:[281,278,550,542,643]},
{name:'ssa::splitter + ssa::as_int',data:[157,139,160,294,278]},
{name:'ssa::splitf + functor',data:[215,126,198,214,337]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs25" > < h4 > < a id = "bs151373809886162287550" href = "#bs151373809886162287550" > #< / a > Replace symbols in text ~400 symbols< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1221" > Naive (and wrong) replace symbols with std::string find + replace< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' & ' , " & amp;" },
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" }
};
auto repl_all = [](std::string& str, char s, std::string_view repl) {
size_t start_pos = 0;
while((start_pos = str.find(s, start_pos)) != std::string::npos) {
str.replace(start_pos, 1, repl);
start_pos += repl.length();
}
};
for (auto _: state) {
std::string result{source};
for (const auto& r : repl) {
repl_all(result, r.first, r.second);
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Это наивная реализация, которая неверно отработает на
таких заменах, как 'a'->'b' и 'b'->'a'. Н о если замены не конфликтуют,
2026-01-21 11:59:17 +00:00
то работает быстро.
This is a naive implementation that will fail to handle substitutions
such as 'a'->'b' and 'b'->'a'. But if the substitutions don't conflict,
2026-02-03 07:38:21 +00:00
it works quickly.< / span > < / span > < / td > < td class = "benchmarkresult" > 1000< / td > < td class = "benchmarkresult" > 826< / td > < td class = "benchmarkresult" > 1118< / td > < td class = "benchmarkresult" > 1301< / td > < td class = "benchmarkresult" > 3545< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1275" > replace symbols with std::string find_first_of + replace< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
std::string result{source};
std::string pattern;
for (const auto& r : repl) {
pattern += r.first;
}
size_t start_pos = 0;
while((start_pos = result.find_first_of(pattern, start_pos)) != std::string::npos) {
size_t idx = pattern.find(result[start_pos]);
result.replace(start_pos, 1, repl[idx].second);
start_pos += repl[idx].second.length();
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Дальше уже правильные реализации, не зависящие от конфликтующих замен.
Further, there are correct implementations that do not depend on
2026-02-03 07:38:21 +00:00
conflicting replacements.< / span > < / span > < / td > < td class = "benchmarkresult" > 2679< / td > < td class = "benchmarkresult" > 2461< / td > < td class = "benchmarkresult" > 1990< / td > < td class = "benchmarkresult" > 2225< / td > < td class = "benchmarkresult" > 4741< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1329" > replace symbols with std::string_view find_first_of + copy< / a > < span class = "tooltiptext code" > void ReplaceSymbolsStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
const std::string_view repl_from = " -< >' \" & " ;
const std::string_view repl_to[] = {" " , " & lt;" , " & gt;" , " & #39;" , " & quot;" , " & amp;" };
for (auto _: state) {
std::string result;
for (size_t start = 0; start < source.size();) {
size_t idx = source.find_first_of(repl_from, start);
if (idx == std::string::npos) {
result += source.substr(start);
break;
}
if (idx > start) {
result += source.substr(start, idx - start);
}
size_t what = repl_from.find(source[idx]);
result += repl_to[what];
start = idx + 1;
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1109< / td > < td class = "benchmarkresult" > 1030< / td > < td class = "benchmarkresult" > 2369< / td > < td class = "benchmarkresult" > 2546< / td > < td class = "benchmarkresult" > 3504< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1382" > replace runtime symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1267< / td > < td class = "benchmarkresult" > 1459< / td > < td class = "benchmarkresult" > 1454< / td > < td class = "benchmarkresult" > 1619< / td > < td class = "benchmarkresult" > 3605< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1382" > replace runtime symbols with simstr and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1002< / td > < td class = "benchmarkresult" > 1014< / td > < td class = "benchmarkresult" > 1391< / td > < td class = "benchmarkresult" > 1434< / td > < td class = "benchmarkresult" > 3154< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1429" > replace const symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1150< / td > < td class = "benchmarkresult" > 1221< / td > < td class = "benchmarkresult" > 1223< / td > < td class = "benchmarkresult" > 1277< / td > < td class = "benchmarkresult" > 2939< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1429" > replace const symbols with string expressions and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
" ksjd-fksjd \" dkjfs-jkhdf dfj ' kdkd \" dkfdkfkdjf"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
" ksjdfksjd & quot;dkjfsjkhdf dfj & #39; kdkd & quot;dkfdkfkdjf"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 870< / td > < td class = "benchmarkresult" > 855< / td > < td class = "benchmarkresult" > 1106< / td > < td class = "benchmarkresult" > 1218< / td > < td class = "benchmarkresult" > 2859< / td > < / tr >
< / 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 5 ' , t e s t s : [
{name:'Naive (and wrong) replace symbols with std::string find + replace',data:[1000,826,1118,1301,3545]},
{name:'replace symbols with std::string find_first_of + replace',data:[2679,2461,1990,2225,4741]},
{name:'replace symbols with std::string_view find_first_of + copy',data:[1109,1030,2369,2546,3504]},
{name:'replace runtime symbols with string expressions and without remembering all search results',data:[1267,1459,1454,1619,3605]},
{name:'replace runtime symbols with simstr and memorization of all search results',data:[1002,1014,1391,1434,3154]},
{name:'replace const symbols with string expressions and without remembering all search results',data:[1150,1221,1223,1277,2939]},
{name:'replace const symbols with string expressions and memorization of all search results',data:[870,855,1106,1218,2859]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs26" > < h4 > < a id = "bs96756339547767401190" href = "#bs96756339547767401190" > #< / a > Replace symbols in text ~40 symbols< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1483" > Short Naive (and wrong) replace symbols with std::string find + replace< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' & ' , " & amp;" },
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" }
};
auto repl_all = [](std::string& str, char s, std::string_view repl) {
size_t start_pos = 0;
while((start_pos = str.find(s, start_pos)) != std::string::npos) {
str.replace(start_pos, 1, repl);
start_pos += repl.length();
}
};
for (auto _: state) {
std::string result{source};
for (const auto& r : repl) {
repl_all(result, r.first, r.second);
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 172< / td > < td class = "benchmarkresult" > 161< / td > < td class = "benchmarkresult" > 319< / td > < td class = "benchmarkresult" > 332< / td > < td class = "benchmarkresult" > 436< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1523" > Short replace symbols with std::string find_first_of + replace< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, std::string_view>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
std::string result{source};
std::string pattern;
for (const auto& r : repl) {
pattern += r.first;
}
size_t start_pos = 0;
while((start_pos = result.find_first_of(pattern, start_pos)) != std::string::npos) {
size_t idx = pattern.find(result[start_pos]);
result.replace(start_pos, 1, repl[idx].second);
start_pos += repl[idx].second.length();
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 322< / td > < td class = "benchmarkresult" > 353< / td > < td class = "benchmarkresult" > 371< / td > < td class = "benchmarkresult" > 428< / td > < td class = "benchmarkresult" > 510< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1563" > Short replace symbols with std::string_view find_first_of + copy< / a > < span class = "tooltiptext code" > void ShortReplaceSymbolsStdString(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
std::string_view source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
const std::string_view repl_from = " -< >' \" & " ;
const std::string_view repl_to[] = {" " , " & lt;" , " & gt;" , " & #39;" , " & quot;" , " & amp;" };
for (auto _: state) {
std::string result;
for (size_t start = 0; start < source.size();) {
size_t idx = source.find_first_of(repl_from, start);
if (idx == std::string::npos) {
result += source.substr(start);
break;
}
if (idx > start) {
result += source.substr(start, idx - start);
}
size_t what = repl_from.find_first_of(source[idx]);
result += repl_to[what];
start = idx + 1;
}
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 167< / td > < td class = "benchmarkresult" > 171< / td > < td class = "benchmarkresult" > 327< / td > < td class = "benchmarkresult" > 356< / td > < td class = "benchmarkresult" > 440< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1602" > Short replace runtime symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 192< / td > < td class = "benchmarkresult" > 268< / td > < td class = "benchmarkresult" > 319< / td > < td class = "benchmarkresult" > 386< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1602" > Short replace runtime symbols with simstr and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
std::vector< std::pair< u8s, ssa>> repl = {
{' -' , " " },
{' < ' , " & lt;" },
{' >' , " & gt;" },
{' \' ' , " & #39;" },
{' \" ' , " & quot;" },
{' & ' , " & amp;" },
};
for (auto _: state) {
stringa result = expr_replace_symbols< u8s, UseVector>{source, repl};
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 185< / td > < td class = "benchmarkresult" > 195< / td > < td class = "benchmarkresult" > 388< / td > < td class = "benchmarkresult" > 383< / td > < td class = "benchmarkresult" > 420< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1635" > Short replace const symbols with string expressions and without remembering all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 144< / td > < td class = "benchmarkresult" > 178< / td > < td class = "benchmarkresult" > 241< / td > < td class = "benchmarkresult" > 267< / td > < td class = "benchmarkresult" > 260< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1635" > Short replace const symbols with string expressions and memorization of all search results< / a > < span class = "tooltiptext code" > template< bool UseVector>
2025-04-05 14:21:11 +00:00
void ShortReplaceSymbolsCons2PatternSimStr(benchmark::State& state) {
stra source =
" abcdefg124 < jhsfjsh sjdfsh jfhjd & & jdjdj >"
;
for (auto _: state) {
stringa result = e_repl_const_symbols< UseVector>(source,
' -' , " " ,
' < ' , " & lt;" ,
' >' , " & gt;" ,
' \' ' , " & #39;" ,
' \" ' , " & quot;" ,
' & ' , " & amp;"
);
#ifdef CHECK_RESULT
if (result
!=
" abcdefg124 & lt; jhsfjsh sjdfsh jfhjd & amp;& amp; jdjdj & gt;"
) {
state.SkipWithError(" not equal" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 143< / td > < td class = "benchmarkresult" > 181< / td > < td class = "benchmarkresult" > 279< / td > < td class = "benchmarkresult" > 355< / td > < td class = "benchmarkresult" > 313< / td > < / tr >
< / 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 6 ' , t e s t s : [
{name:'Short Naive (and wrong) replace symbols with std::string find + replace',data:[172,161,319,332,436]},
{name:'Short replace symbols with std::string find_first_of + replace',data:[322,353,371,428,510]},
{name:'Short replace symbols with std::string_view find_first_of + copy',data:[167,171,327,356,440]},
{name:'Short replace runtime symbols with string expressions and without remembering all search results',data:[181,192,268,319,386]},
{name:'Short replace runtime symbols with simstr and memorization of all search results',data:[185,195,388,383,420]},
{name:'Short replace const symbols with string expressions and without remembering all search results',data:[144,178,241,267,260]},
{name:'Short replace const symbols with string expressions and memorization of all search results',data:[143,181,279,355,313]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs27" > < h4 > < a id = "bs77745698784557935900" href = "#bs77745698784557935900" > #< / a > Replace All Str To Longer Size< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1674" > replace bb to ---- in std::string|64< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 156< / td > < td class = "benchmarkresult" > 183< / td > < td class = "benchmarkresult" > 240< / td > < td class = "benchmarkresult" > 275< / td > < td class = "benchmarkresult" > 377< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1674" > replace bb to ---- in std::string|256< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 525< / td > < td class = "benchmarkresult" > 499< / td > < td class = "benchmarkresult" > 858< / td > < td class = "benchmarkresult" > 899< / td > < td class = "benchmarkresult" > 1421< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1674" > replace bb to ---- in std::string|512< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1042< / td > < td class = "benchmarkresult" > 1012< / td > < td class = "benchmarkresult" > 1446< / td > < td class = "benchmarkresult" > 1632< / td > < td class = "benchmarkresult" > 2623< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1674" > replace bb to ---- in std::string|1024< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2418< / td > < td class = "benchmarkresult" > 2304< / td > < td class = "benchmarkresult" > 3194< / td > < td class = "benchmarkresult" > 3318< / td > < td class = "benchmarkresult" > 5482< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1674" > replace bb to ---- in std::string|2048< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " ----" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 5883< / td > < td class = "benchmarkresult" > 5796< / td > < td class = "benchmarkresult" > 7825< / td > < td class = "benchmarkresult" > 8116< / td > < td class = "benchmarkresult" > 13478< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1708" > replace bb to ---- in lstringa< 8>|64< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 144< / td > < td class = "benchmarkresult" > 154< / td > < td class = "benchmarkresult" > 224< / td > < td class = "benchmarkresult" > 235< / td > < td class = "benchmarkresult" > 311< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1708" > replace bb to ---- in lstringa< 8>|256< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 529< / td > < td class = "benchmarkresult" > 484< / td > < td class = "benchmarkresult" > 619< / td > < td class = "benchmarkresult" > 686< / td > < td class = "benchmarkresult" > 1149< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1708" > replace bb to ---- in lstringa< 8>|512< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 880< / td > < td class = "benchmarkresult" > 886< / td > < td class = "benchmarkresult" > 1083< / td > < td class = "benchmarkresult" > 1108< / td > < td class = "benchmarkresult" > 2165< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1708" > replace bb to ---- in lstringa< 8>|1024< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1805< / td > < td class = "benchmarkresult" > 1917< / td > < td class = "benchmarkresult" > 1886< / td > < td class = "benchmarkresult" > 2042< / td > < td class = "benchmarkresult" > 3868< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1708" > replace bb to ---- in lstringa< 8>|2048< / a > < span class = "tooltiptext code" > template< size_t N, size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " ----" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3265< / td > < td class = "benchmarkresult" > 3636< / td > < td class = "benchmarkresult" > 3625< / td > < td class = "benchmarkresult" > 3933< / td > < td class = "benchmarkresult" > 7737< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1731" > replace bb to ---- by init stringa|64< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
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-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 107< / td > < td class = "benchmarkresult" > 99.5< / td > < td class = "benchmarkresult" > 177< / td > < td class = "benchmarkresult" > 205< / td > < td class = "benchmarkresult" > 226< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1731" > replace bb to ---- by init stringa|256< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
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-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 313< / td > < td class = "benchmarkresult" > 297< / td > < td class = "benchmarkresult" > 371< / td > < td class = "benchmarkresult" > 475< / td > < td class = "benchmarkresult" > 790< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1731" > replace bb to ---- by init stringa|512< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
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-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 751< / td > < td class = "benchmarkresult" > 717< / td > < td class = "benchmarkresult" > 813< / td > < td class = "benchmarkresult" > 1039< / td > < td class = "benchmarkresult" > 1685< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1731" > replace bb to ---- by init stringa|1024< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
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-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1657< / td > < td class = "benchmarkresult" > 1663< / td > < td class = "benchmarkresult" > 1634< / td > < td class = "benchmarkresult" > 2165< / td > < td class = "benchmarkresult" > 3603< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1731" > replace bb to ---- by init stringa|2048< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
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-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3126< / td > < td class = "benchmarkresult" > 3325< / td > < td class = "benchmarkresult" > 3081< / td > < td class = "benchmarkresult" > 4423< / td > < td class = "benchmarkresult" > 7600< / td > < / tr >
< / 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 7 ' , t e s t s : [
{name:'replace bb to ---- in std::string|64',data:[156,183,240,275,377]},
{name:'replace bb to ---- in std::string|256',data:[525,499,858,899,1421]},
{name:'replace bb to ---- in std::string|512',data:[1042,1012,1446,1632,2623]},
{name:'replace bb to ---- in std::string|1024',data:[2418,2304,3194,3318,5482]},
{name:'replace bb to ---- in std::string|2048',data:[5883,5796,7825,8116,13478]},
{name:'replace bb to ---- in lstringa< 8 > |64',data:[144,154,224,235,311]},
{name:'replace bb to ---- in lstringa< 8 > |256',data:[529,484,619,686,1149]},
{name:'replace bb to ---- in lstringa< 8 > |512',data:[880,886,1083,1108,2165]},
{name:'replace bb to ---- in lstringa< 8 > |1024',data:[1805,1917,1886,2042,3868]},
{name:'replace bb to ---- in lstringa< 8 > |2048',data:[3265,3636,3625,3933,7737]},
{name:'replace bb to ---- by init stringa|64',data:[107,99.5,177,205,226]},
{name:'replace bb to ---- by init stringa|256',data:[313,297,371,475,790]},
{name:'replace bb to ---- by init stringa|512',data:[751,717,813,1039,1685]},
{name:'replace bb to ---- by init stringa|1024',data:[1657,1663,1634,2165,3603]},
{name:'replace bb to ---- by init stringa|2048',data:[3126,3325,3081,4423,7600]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs28" > < h4 > < a id = "bs74494088982050398630" href = "#bs74494088982050398630" > #< / a > Replace All Str To Same Size< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1753" > replace bb to -- in std::string|64< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 120< / td > < td class = "benchmarkresult" > 123< / td > < td class = "benchmarkresult" > 195< / td > < td class = "benchmarkresult" > 212< / td > < td class = "benchmarkresult" > 268< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1753" > replace bb to -- in std::string|256< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 404< / td > < td class = "benchmarkresult" > 383< / td > < td class = "benchmarkresult" > 477< / td > < td class = "benchmarkresult" > 528< / td > < td class = "benchmarkresult" > 987< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1753" > replace bb to -- in std::string|512< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 761< / td > < td class = "benchmarkresult" > 719< / td > < td class = "benchmarkresult" > 875< / td > < td class = "benchmarkresult" > 969< / td > < td class = "benchmarkresult" > 1942< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1753" > replace bb to -- in std::string|1024< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1606< / td > < td class = "benchmarkresult" > 1415< / td > < td class = "benchmarkresult" > 1630< / td > < td class = "benchmarkresult" > 1820< / td > < td class = "benchmarkresult" > 3660< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1753" > replace bb to -- in std::string|2048< / a > < span class = "tooltiptext code" > template< size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualStdString(benchmark::State& state) {
std::string_view source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
std::string_view sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
std::string_view pattern = " bb" ;
std::string_view repl = " --" ;
std::string big_source, big_sample;
for (int i = 0; i < Long; i++) {
big_source += source;
big_sample += sample;
}
for (auto _: state) {
std::string result{big_source};
size_t start_pos = 0;
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
result.replace(start_pos, pattern.length(), repl);
start_pos += repl.length();
}
#ifdef CHECK_RESULT
if (result != big_sample) {
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 3280< / td > < td class = "benchmarkresult" > 2838< / td > < td class = "benchmarkresult" > 3278< / td > < td class = "benchmarkresult" > 3585< / td > < td class = "benchmarkresult" > 7038< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1786" > replace bb to -- in lstringa< 8>|64< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 104< / td > < td class = "benchmarkresult" > 102< / td > < td class = "benchmarkresult" > 182< / td > < td class = "benchmarkresult" > 190< / td > < td class = "benchmarkresult" > 229< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1786" > replace bb to -- in lstringa< 8>|256< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 312< / td > < td class = "benchmarkresult" > 300< / td > < td class = "benchmarkresult" > 440< / td > < td class = "benchmarkresult" > 475< / td > < td class = "benchmarkresult" > 776< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1786" > replace bb to -- in lstringa< 8>|512< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 591< / td > < td class = "benchmarkresult" > 562< / td > < td class = "benchmarkresult" > 847< / td > < td class = "benchmarkresult" > 904< / td > < td class = "benchmarkresult" > 1461< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1786" > replace bb to -- in lstringa< 8>|1024< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1139< / td > < td class = "benchmarkresult" > 1116< / td > < td class = "benchmarkresult" > 1580< / td > < td class = "benchmarkresult" > 1626< / td > < td class = "benchmarkresult" > 2897< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1786" > replace bb to -- in lstringa< 8>|2048< / a > < span class = "tooltiptext code" > template< size_t N, size_t Long>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimString(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
lstringa< 2048> big_source{Long, source}, big_sample{Long, sample};
for (auto _: state) {
lstringa< N> result = big_source;
result.replace(" bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 2679< / td > < td class = "benchmarkresult" > 2185< / td > < td class = "benchmarkresult" > 2828< / td > < td class = "benchmarkresult" > 3152< / td > < td class = "benchmarkresult" > 5674< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1808" > replace bb to -- by init stringa|64< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 91.0< / td > < td class = "benchmarkresult" > 97.1< / td > < td class = "benchmarkresult" > 153< / td > < td class = "benchmarkresult" > 172< / td > < td class = "benchmarkresult" > 187< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1808" > replace bb to -- by init stringa|256< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 242< / td > < td class = "benchmarkresult" > 274< / td > < td class = "benchmarkresult" > 355< / td > < td class = "benchmarkresult" > 397< / td > < td class = "benchmarkresult" > 652< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1808" > replace bb to -- by init stringa|512< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 431< / td > < td class = "benchmarkresult" > 544< / td > < td class = "benchmarkresult" > 599< / td > < td class = "benchmarkresult" > 673< / td > < td class = "benchmarkresult" > 1221< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1808" > replace bb to -- by init stringa|1024< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 914< / td > < td class = "benchmarkresult" > 1481< / td > < td class = "benchmarkresult" > 1077< / td > < td class = "benchmarkresult" > 1258< / td > < td class = "benchmarkresult" > 2366< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1808" > replace bb to -- by init stringa|2048< / a > < span class = "tooltiptext code" > template< size_t Count>
2025-04-05 14:21:11 +00:00
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
ssa source = " aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba" ;
ssa sample = " aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a" ;
ssa pattern = " bb" ;
ssa repl = " --" ;
2025-11-26 19:15:50 +00:00
2025-04-05 14:21:11 +00:00
lstringa< 2048> big_source{Count, source}, big_sample{Count, sample};
for (auto _: state) {
stringa result = e_repl(big_source.to_str(), " bb" , " --" );
#ifdef CHECK_RESULT
if (result.to_str() != big_sample) {
std::cout < < result.length() < < " : " < < result < < " \n\n" < < big_sample.length() < < " : " < < big_sample < < " \n\n" ;
state.SkipWithError(" error in replace" );
break;
}
#endif
benchmark::DoNotOptimize(result);
benchmark::DoNotOptimize(source);
benchmark::DoNotOptimize(pattern);
benchmark::DoNotOptimize(repl);
}
2026-02-03 07:38:21 +00:00
}< / span > < / span > < / td > < td > < / td > < td class = "benchmarkresult" > 1647< / td > < td class = "benchmarkresult" > 2397< / td > < td class = "benchmarkresult" > 2138< / td > < td class = "benchmarkresult" > 2330< / td > < td class = "benchmarkresult" > 5259< / td > < / tr >
< / 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 8 ' , t e s t s : [
{name:'replace bb to -- in std::string|64',data:[120,123,195,212,268]},
{name:'replace bb to -- in std::string|256',data:[404,383,477,528,987]},
{name:'replace bb to -- in std::string|512',data:[761,719,875,969,1942]},
{name:'replace bb to -- in std::string|1024',data:[1606,1415,1630,1820,3660]},
{name:'replace bb to -- in std::string|2048',data:[3280,2838,3278,3585,7038]},
{name:'replace bb to -- in lstringa< 8 > |64',data:[104,102,182,190,229]},
{name:'replace bb to -- in lstringa< 8 > |256',data:[312,300,440,475,776]},
{name:'replace bb to -- in lstringa< 8 > |512',data:[591,562,847,904,1461]},
{name:'replace bb to -- in lstringa< 8 > |1024',data:[1139,1116,1580,1626,2897]},
{name:'replace bb to -- in lstringa< 8 > |2048',data:[2679,2185,2828,3152,5674]},
{name:'replace bb to -- by init stringa|64',data:[91.0,97.1,153,172,187]},
{name:'replace bb to -- by init stringa|256',data:[242,274,355,397,652]},
{name:'replace bb to -- by init stringa|512',data:[431,544,599,673,1221]},
{name:'replace bb to -- by init stringa|1024',data:[914,1481,1077,1258,2366]},
{name:'replace bb to -- by init stringa|2048',data:[1647,2397,2138,2330,5259]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs29" > < h4 > < a id = "bs8410196985047277720" href = "#bs8410196985047277720" > #< / a > Hash Map insert and find< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1905" > hashStrMapA< size_t> emplace & find stringa;< / a > < span class = "tooltiptext code" > void HashMapSimStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
hashStrMapA< size_t> store;
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
store.try_emplace(bs_sim[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_sim.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
auto find = store.find(bs_sim[idx]);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вставляем в hashStrMapA 10000 stringa длиной от 30 до 50
2026-01-21 11:59:17 +00:00
символов, а потом ищем их в ней
We insert 10,000 strings of length from 30 to 50 characters into
2026-02-03 07:38:21 +00:00
hashStrMapA, and then search for them in it.< / span > < / span > < / td > < td class = "benchmarkresult" > 3546428< / td > < td class = "benchmarkresult" > 3640422< / td > < td class = "benchmarkresult" > 3978350< / td > < td class = "benchmarkresult" > 4361265< / td > < td class = "benchmarkresult" > 3192661< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1929" > std::unordered_map< std::string, size_t> emplace & find std::string;< / a > < span class = "tooltiptext code" > void HashMapStdStr(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::unordered_map< std::string, size_t> store;
for (size_t idx = 0; idx < bs_std.size(); idx++) {
store.try_emplace(bs_std[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_std.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_std.size(); idx++) {
auto find = store.find(bs_std[idx]);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Т о же самое c std::string и std::unordered_map
2026-02-03 07:38:21 +00:00
Same thing with std::string and std::unordered_map< / span > < / span > < / td > < td class = "benchmarkresult" > 3486975< / td > < td class = "benchmarkresult" > 3537855< / td > < td class = "benchmarkresult" > 5607567< / td > < td class = "benchmarkresult" > 5878463< / td > < td class = "benchmarkresult" > 3399083< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1953" > hashStrMapA< size_t> emplace & find ssa;< / a > < span class = "tooltiptext code" > void HashMapSimSsa(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
hashStrMapA< size_t> store;
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
store.emplace(bs_sim[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_sim.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
ssa key = bs_sim[idx];
auto find = store.find(key);
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Теперь вставляем stringa, а ищем ssa
2026-02-03 07:38:21 +00:00
Now we insert stringa and search for ssa< / span > < / span > < / td > < td class = "benchmarkresult" > 3592544< / td > < td class = "benchmarkresult" > 3721221< / td > < td class = "benchmarkresult" > 3489211< / td > < td class = "benchmarkresult" > 3945892< / td > < td class = "benchmarkresult" > 3300905< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L1978" > std::unordered_map< std::string, size_t> emplace & find std::string_view;< / a > < span class = "tooltiptext code" > void HashMapStdStrView(benchmark::State& state) {
2025-04-05 14:21:11 +00:00
for (auto _: state) {
std::unordered_map< std::string, size_t> store;
for (size_t idx = 0; idx < bs_std.size(); idx++) {
store.emplace(bs_std[idx], idx);
}
#ifdef CHECK_RESULT
if (store.size() != bs_std.size()) {
state.SkipWithError(" bad inserts" );
}
#endif
for (size_t idx = 0; idx < bs_std.size(); idx++) {
std::string_view key = bs_std[idx];
auto find = store.find(std::string{key});
size_t res = find->second;
#ifdef CHECK_RESULT
if (res != idx) {
state.SkipWithError(" bad find" );
}
#endif
benchmark::DoNotOptimize(res);
}
}
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Вставляем std::string, а ищем std::string_view
2026-02-03 07:38:21 +00:00
We insert std::string and look for std::string_view< / span > < / span > < / td > < td class = "benchmarkresult" > 3988653< / td > < td class = "benchmarkresult" > 3973701< / td > < td class = "benchmarkresult" > 6249698< / td > < td class = "benchmarkresult" > 6313765< / td > < td class = "benchmarkresult" > 3845092< / td > < / tr >
< / 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 9 ' , t e s t s : [
{name:'hashStrMapA< size_t > emplace & find stringa;',data:[3546428,3640422,3978350,4361265,3192661]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string;',data:[3486975,3537855,5607567,5878463,3399083]},
{name:'hashStrMapA< size_t > emplace & find ssa;',data:[3592544,3721221,3489211,3945892,3300905]},
{name:'std::unordered_map< std::string , size_t > emplace & find std::string_view;',data:[3988653,3973701,6249698,6313765,3845092]}
2025-04-05 14:21:11 +00:00
]}< / script >
2026-02-03 07:38:21 +00:00
< div class = "benchset" id = "bs30" > < h4 > < a id = "bs131384792586914680410" href = "#bs131384792586914680410" > #< / a > Build Full Func Name< / h4 >
2026-01-21 11:59:17 +00:00
< table > < thead > < tr > < th > Benchmark name< / th > < th width = "5%" > Comment< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21< / th > < th width = "8%" > Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, Clang-19< / th > < th width = "8%" > Xeon E5-2682 v4, Windows 10, MSVC-19< / th > < th width = "8%" > Xeon E5-2682 v4, WASM Firefox, Clang-21< / th > < / tr > < / thead > < tbody >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L2188" > Build func full name std::string;< / a > < span class = "tooltiptext code" > std::string build_full_name_std() const {
2025-04-05 14:21:11 +00:00
std::string str{has_ret_type_resolver ? " any" sv : type_names_sv[(unsigned)ret_type]};
str += " " ;
str += std_name;
str += " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str += " , " ;
}
if (param.optional) {
str += " [" ;
}
param.allowed_types.to_stdstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str += " , " ;
}
str += " ..." ;
}
str += " )" ;
//std::cout < < " Len=" < < str.length() < < " , Cap=" < < str.capacity() < < " \n" ;
return str;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Обыденная задача, подобные часто могут встретится в работе:
По неким данным сгенерировать текст. В этом случае по данным
о неких функциях сформировать их полное имя с типами параметров и
2026-01-21 11:59:17 +00:00
возвращаемого значения. Алгоритм на std::string.
A common task, similar to this one, can often be encountered in work:
Generate text from given data. In this case, using data
on certain functions, generate their full names with parameter types and
2026-02-03 07:38:21 +00:00
return values. The algorithm uses std::string.< / span > < / span > < / td > < td class = "benchmarkresult" > 697< / td > < td class = "benchmarkresult" > 916< / td > < td class = "benchmarkresult" > 1507< / td > < td class = "benchmarkresult" > 1644< / td > < td class = "benchmarkresult" > 3032< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L2220" > Build func full name std::string 1;< / a > < span class = "tooltiptext code" > std::string build_full_name_std1() const {
2025-04-05 14:21:11 +00:00
std::string str{has_ret_type_resolver ? " any" sv : type_names_sv[(unsigned)ret_type]};
str += " " + std_name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str += " , " ;
}
if (param.optional) {
str += " [" ;
}
param.allowed_types.to_stdstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str += " , " ;
}
str += " ..." ;
}
str += " )" ;
//std::cout < < " Len=" < < str.length() < < " , Cap=" < < str.capacity() < < " \n" ;
return str;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Почти тот же алгоритм, но несколько последовательных
2026-01-21 11:59:17 +00:00
+= к строке заменены на одно += + + +.
Almost the same algorithm, but several consecutive
2026-02-03 07:38:21 +00:00
+= to a string are replaced with a single += + + +.< / span > < / span > < / td > < td class = "benchmarkresult" > 803< / td > < td class = "benchmarkresult" > 1081< / td > < td class = "benchmarkresult" > 1543< / td > < td class = "benchmarkresult" > 1749< / td > < td class = "benchmarkresult" > 3434< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L2250" > Build func full name std::stream;< / a > < span class = "tooltiptext code" > std::string build_full_name_stream() const {
2025-04-05 14:21:11 +00:00
std::ostringstream str;
if (has_ret_type_resolver) {
str < < " any" ;
} else {
str < < type_names_sv[(unsigned)ret_type];
}
str < < " " < < std_name < < " (" ;
bool add_comma = false;
for (const auto& param : params) {
if (add_comma) {
str < < " , " ;
}
if (param.optional) {
str < < " [" ;
}
param.allowed_types.to_stream(str);
if (param.optional) {
str < < " ]" ;
}
add_comma = true;
}
if (unlim_params) {
if (add_comma) {
str < < " , " ;
}
str < < " ..." ;
}
str < < " )" ;
return str.str();
2026-01-21 11:59:17 +00:00
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Строим имя функции через std::ostringstream и < <
2026-02-03 07:38:21 +00:00
We construct the function name through std::ostringstream and < < < / span > < / span > < / td > < td class = "benchmarkresult" > 2540< / td > < td class = "benchmarkresult" > 2581< / td > < td class = "benchmarkresult" > 8087< / td > < td class = "benchmarkresult" > 9940< / td > < td class = "benchmarkresult" > 7330< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L2161" > Build func full name stringa;< / a > < span class = "tooltiptext code" > stringa build_full_name() const {
2025-04-05 14:21:11 +00:00
lstringa< 512> str = e_choice(has_ret_type_resolver, " any" , type_names[(unsigned)ret_type]) + " " + name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
str += e_if(add_comma, " , " ) + e_if(param.optional, " [" );
param.allowed_types.to_simstr(str);
if (param.optional) {
str += " ]" ;
}
add_comma = true;
}
return str + e_if(unlim_params, e_if(add_comma, " , " ) + " ..." ) + " )" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Реализация на simstr строках и строковых выражениях.
2026-01-21 11:59:17 +00:00
Инфа о параметрах добавляется в текущую строку
Implementation using simstr strings and string expressions.
2026-02-03 07:38:21 +00:00
Parameter information is appended to the current line.< / span > < / span > < / td > < td class = "benchmarkresult" > 507< / td > < td class = "benchmarkresult" > 478< / td > < td class = "benchmarkresult" > 823< / td > < td class = "benchmarkresult" > 937< / td > < td class = "benchmarkresult" > 1429< / td > < / tr >
2026-02-03 20:28:15 +00:00
< tr > < td class = "benchmarkname" > < span class = "tooltip" > < a target = "blank" href = "https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L2176" > Build func full name stringa 1;< / a > < span class = "tooltiptext code" > stringa build_full_name1() const {
2025-04-05 14:21:11 +00:00
lstringa< 512> str = e_choice(has_ret_type_resolver, " any" , type_names[(unsigned)ret_type]) + " " + name + " (" ;
bool add_comma = false;
for (const auto& param : params) {
str += e_if(add_comma, " , " ) + e_if(param.optional, " [" ) + param.allowed_types.get_simstr() + e_if(param.optional, " ]" );
add_comma = true;
}
return str + e_if(unlim_params, e_if(add_comma, " , " ) + " ..." ) + " )" ;
}< / span > < / span > < / td > < td > < span class = "tooltip info" > >> < span class = "tooltiptext" > Реализация на simstr строках и строковых выражениях.
Инфа о параметрах добавляется во временную строку, а потом
разом добавляется в текущую строку. Позволяет операции в цикле
2026-01-21 11:59:17 +00:00
записать в одну строку, но чуть проигрывает по времени выполнения.
Implementation using simstr strings and string expressions.
Parameter information is added to a temporary string, and then
all at once to the current string. This allows loop operations
2026-02-03 07:38:21 +00:00
to be written in a single string, but is slightly slower in execution time.< / span > < / span > < / td > < td class = "benchmarkresult" > 655< / td > < td class = "benchmarkresult" > 710< / td > < td class = "benchmarkresult" > 939< / td > < td class = "benchmarkresult" > 1058< / td > < td class = "benchmarkresult" > 1643< / td > < / tr >
< / tbody > < / table > < / div > < script > b e n c h _ s e t s [ ' B u i l d F u l l F u n c N a m e ' ] = { i d : ' b s 3 0 ' , t e s t s : [
{name:'Build func full name std::string;',data:[697,916,1507,1644,3032]},
{name:'Build func full name std::string 1;',data:[803,1081,1543,1749,3434]},
{name:'Build func full name std::stream;',data:[2540,2581,8087,9940,7330]},
{name:'Build func full name stringa;',data:[507,478,823,937,1429]},
{name:'Build func full name stringa 1;',data:[655,710,939,1058,1643]}
2025-11-26 19:15:50 +00:00
]}< / script > < / body > < / html >