mirror of https://github.com/orefkov/simstr.git
4361 lines
295 KiB
HTML
4361 lines
295 KiB
HTML
<html>
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<link href="results.css" rel="stylesheet" />
|
||
<title>SimStr benchmarks results</title>
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||
<script>
|
||
let bench_sets = {};
|
||
let activeBuilder = buildTestsByPlatformsBar;
|
||
let buildAsLine = {
|
||
"Copy not literal Str with N symbols": "Length of the copied string",
|
||
"Replace All Str To Longer Size": "Length of the string to be replaced",
|
||
"Replace All Str To Same Size": "Length of the string to be replaced"
|
||
};
|
||
function hl() {
|
||
document.querySelectorAll('.tooltiptext.code').forEach((el) => {
|
||
hljs.highlightElement(el);
|
||
});
|
||
}
|
||
function addBarChart(id, data) {
|
||
let canvas = document.getElementById('chart' + id);
|
||
new Chart(canvas, {
|
||
type: 'bar',
|
||
data: data,
|
||
options: {
|
||
scales: {
|
||
y: {
|
||
beginAtZero: true
|
||
},
|
||
x: {
|
||
title: {
|
||
text: "Time (ns)",
|
||
display: true
|
||
}
|
||
}
|
||
},
|
||
indexAxis: 'y',
|
||
plugins: {
|
||
legend: {
|
||
position: 'right',
|
||
labels: {
|
||
font: {
|
||
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function platformChecked(idx) {
|
||
return document.getElementById('pl' + idx).checked;
|
||
}
|
||
function buildPlatformsByTestsBar(bsName) {
|
||
if (buildAsLine[bsName]) {
|
||
buildPlatformsByTestsLine(bsName, buildAsLine[bsName]);
|
||
return;
|
||
}
|
||
let data = { labels: [], datasets: [] };
|
||
for (const i in platform_names) {
|
||
if (platformChecked(i))
|
||
data.datasets.push({ label: platform_names[i], data: [], borderWidth: 1 });
|
||
}
|
||
let bs = bench_sets[bsName];
|
||
for (const test of bs.tests) {
|
||
data.labels.push(test.name);
|
||
let ds = 0;
|
||
for (const i in test.data) {
|
||
if (platformChecked(i)) {
|
||
data.datasets[ds++].data.push(test.data[i]);
|
||
}
|
||
}
|
||
}
|
||
addBarChart(bs.id, data);
|
||
}
|
||
function buildTestsByPlatformsBar(bsName) {
|
||
if (buildAsLine[bsName], buildAsLine[bsName]) {
|
||
buildTestsByPlatformsLine(bsName, buildAsLine[bsName]);
|
||
return;
|
||
}
|
||
let data = { labels: [], datasets: [] };
|
||
let bs = bench_sets[bsName];
|
||
for (const test of bs.tests) {
|
||
data.datasets.push({ label: test.name, data: [], borderWidth: 1 });
|
||
}
|
||
for (const i in platform_names) {
|
||
if (platformChecked(i)) {
|
||
data.labels.push(platform_names[i]);
|
||
for (const j in bs.tests) {
|
||
data.datasets[j].data.push(bs.tests[j].data[i]);
|
||
}
|
||
}
|
||
}
|
||
addBarChart(bs.id, data);
|
||
}
|
||
function buildCanvas(plCount) {
|
||
document.querySelectorAll("canvas.bench_chart").forEach(e => e.remove());
|
||
for (var bs_name in bench_sets) {
|
||
let bs = bench_sets[bs_name];
|
||
if (plCount) {
|
||
let canvas = document.createElement('canvas');
|
||
canvas.id = "chart" + bs.id;
|
||
canvas.classList.add('bench_chart');
|
||
let h = 20 * plCount * bs.tests.length;
|
||
canvas.style.width = "100%";
|
||
canvas.style.height = h + "px";
|
||
canvas.height = h * devicePixelRatio;
|
||
document.getElementById(bs.id).after(canvas);
|
||
}
|
||
}
|
||
}
|
||
function addLineChart(canvas, data, title, scaleTitle) {
|
||
new Chart(canvas, {
|
||
type: 'line',
|
||
data: data,
|
||
options: {
|
||
scales: {
|
||
y: {
|
||
beginAtZero: true,
|
||
title: {
|
||
text: scaleTitle,
|
||
display: true
|
||
}
|
||
},
|
||
x: {
|
||
title: {
|
||
text: "Time (ns)",
|
||
display: true
|
||
}
|
||
}
|
||
},
|
||
indexAxis: 'y',
|
||
plugins: {
|
||
title: {
|
||
display: true,
|
||
text: title,
|
||
},
|
||
legend: {
|
||
position: 'right',
|
||
labels: {
|
||
font: {
|
||
family: "'Cascadia Code', Consolas, 'Courier New', Courier, monospace"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function buildTestsByPlatformsLineOne(bs, canvas, plIdx, scaleTitle) {
|
||
let data = { datasets: [] };
|
||
let prevTest = '';
|
||
let curData = undefined;
|
||
for (const test of bs.tests) {
|
||
let m = test.name.match(/(.+)[\/\|](\d+)$/);
|
||
if (m[1] != prevTest) {
|
||
prevTest = m[1];
|
||
curData = { label: prevTest, data: [], borderWidth: 1 };
|
||
data.datasets.push(curData);
|
||
}
|
||
curData.data.push([test.data[plIdx], m[2]]);
|
||
}
|
||
addLineChart(canvas, data, platform_names[plIdx], scaleTitle);
|
||
}
|
||
function buildTestsByPlatformsLine(bsName, scaleTitle) {
|
||
let bs = bench_sets[bsName];
|
||
let canvas = document.getElementById('chart' + bs.id);
|
||
let after = null;
|
||
|
||
for (const i in platform_names) {
|
||
if (platformChecked(i)) {
|
||
if (!canvas) {
|
||
canvas = document.createElement('canvas');
|
||
canvas.classList.add('bench_chart');
|
||
canvas.style.width = "100%";
|
||
after.after(canvas);
|
||
}
|
||
canvas.style.height = "300px";
|
||
canvas.height = 300 * devicePixelRatio;
|
||
buildTestsByPlatformsLineOne(bs, canvas, i, scaleTitle);
|
||
after = canvas;
|
||
canvas = null;
|
||
}
|
||
}
|
||
}
|
||
function buildPlatformsByTestsLineOne(bs, canvas, after, testData, title, scaleTitle) {
|
||
let data = { datasets: [] };
|
||
for (const i in platform_names) {
|
||
if (platformChecked(i)) {
|
||
ds = {label: platform_names[i], data: []};
|
||
for (const test of testData) {
|
||
ds.data.push([test.data[i], test.count]);
|
||
}
|
||
data.datasets.push(ds);
|
||
}
|
||
}
|
||
if (!canvas) {
|
||
canvas = document.createElement('canvas');
|
||
canvas.classList.add('bench_chart');
|
||
canvas.style.width = "100%";
|
||
after.after(canvas);
|
||
}
|
||
canvas.style.height = "300px";
|
||
canvas.height = 300 * devicePixelRatio;
|
||
addLineChart(canvas, data, title, scaleTitle);
|
||
return canvas;
|
||
}
|
||
function buildPlatformsByTestsLine(bsName, scaleTitle) {
|
||
let bs = bench_sets[bsName];
|
||
let canvas = document.getElementById('chart' + bs.id);
|
||
let after = null;
|
||
let data = [];
|
||
let prevTest = '';
|
||
for (const test of bs.tests) {
|
||
let m = test.name.match(/(.+)[\/\|](\d+)$/);
|
||
if (m[1] != prevTest) {
|
||
if (data.length) {
|
||
after = buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
|
||
canvas = null;
|
||
}
|
||
prevTest = m[1];
|
||
data = [];
|
||
}
|
||
data.push({count: m[2], data: test.data});
|
||
}
|
||
if (data.length) {
|
||
buildPlatformsByTestsLineOne(bs, canvas, after, data, prevTest, scaleTitle);
|
||
}
|
||
}
|
||
function buildCharts() {
|
||
let plCount = 0;
|
||
for (const i in platform_names) {
|
||
if (platformChecked(i))
|
||
plCount++;
|
||
}
|
||
buildCanvas(plCount);
|
||
for (var bs_name in bench_sets) {
|
||
activeBuilder(bs_name);
|
||
}
|
||
}
|
||
function switchGrouping() {
|
||
activeBuilder = document.getElementById('gbp').checked ? buildTestsByPlatformsBar : buildPlatformsByTestsBar;
|
||
buildCharts();
|
||
}
|
||
document.addEventListener('DOMContentLoaded', (event) => {
|
||
if (!hljs) {
|
||
let scriptTag = document.createElement('script');
|
||
scriptTag.src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js";
|
||
scriptTag.onload = hl;
|
||
scriptTag.onreadystatechange = hl;
|
||
document.body.appendChild(scriptTag);
|
||
} else {
|
||
hl();
|
||
}
|
||
if (!Chart) {
|
||
let scriptTag = document.createElement('script');
|
||
scriptTag.src = "https://cdn.jsdelivr.net/npm/chart.js";
|
||
scriptTag.onload = buildCharts;
|
||
scriptTag.onreadystatechange = buildCharts;
|
||
document.body.appendChild(scriptTag);
|
||
} else {
|
||
buildCharts();
|
||
}
|
||
});
|
||
</script>
|
||
</head><body><div class="header"><h2>simstr benchmarks results</h2>
|
||
<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>
|
||
<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)
|
||
Load Average: 0.43, 0.77, 0.52
|
||
***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>
|
||
<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)
|
||
Load Average: 0.00, 0.00, 0.00
|
||
***WARNING*** ASLR is enabled, the results may have unreproducible noise in them.</span></span> Include in charts: <input type="checkbox" id="pl1" checked onchange="buildCharts()"/></li>
|
||
<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:
|
||
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>
|
||
<li><span class="platform">Xeon E5-2682 v4, Windows 10, MSVC-19</span><span class="tooltip">32 X 2494 MHz CPU s<span class="tooltiptext">CPU Caches:
|
||
L1 Data 32 KiB (x16)
|
||
L1 Instruction 32 KiB (x16)
|
||
L2 Unified 256 KiB (x16)
|
||
L3 Unified 40960 KiB (x1)</span></span> Include in charts: <input type="checkbox" id="pl3" checked onchange="buildCharts()"/></li>
|
||
<li><span class="platform">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</span><span class="tooltip">32 X 2513.96 MHz CPU s<span class="tooltiptext">Chrome/143.0.0.0 webasm</span></span> Include in charts: <input type="checkbox" id="pl4" checked onchange="buildCharts()"/></li>
|
||
</ul></div></div>
|
||
<script>const platform_names=['Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21','Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13','Xeon E5-2682 v4, Windows 10, Clang-19','Xeon E5-2682 v4, Windows 10, MSVC-19','Xeon E5-2682 v4, WASM Chrome 143, Clang-21'];</script>
|
||
|
||
|
||
<div class="benchset" id="bs1"><h4><a id="bs15359472366966513900" href="#bs15359472366966513900">#</a> Concatenate email</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L94">Concat email std::format</a><span class="tooltiptext code">std::string email_concat_format(std::string_view name, std::string_view domain, std::string_view tld) {
|
||
return std::format("{}@{}.{}", name, domain, tld);
|
||
}</span></span></td><td></td><td class="benchmarkresult">163</td><td class="benchmarkresult">177</td><td class="benchmarkresult">203</td><td class="benchmarkresult">259</td><td class="benchmarkresult">964</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L109">Concat email std::stringstream</a><span class="tooltiptext code">std::string email_concat_stream(std::string_view name, std::string_view domain, std::string_view tld) {
|
||
std::stringstream s;
|
||
s << name << "@" << domain << "." << tld;
|
||
return s.str();
|
||
}</span></span></td><td></td><td class="benchmarkresult">322</td><td class="benchmarkresult">328</td><td class="benchmarkresult">792</td><td class="benchmarkresult">898</td><td class="benchmarkresult">2458</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L60">Concat email stringzilla append</a><span class="tooltiptext code">sz::string email_concat_stringzilla_app(sz::string name, sz::string_view domain, sz::string_view tld) {
|
||
return name.append("@").append(domain).append(".").append(tld);
|
||
}</span></span></td><td></td><td class="benchmarkresult">133</td><td class="benchmarkresult">115</td><td class="benchmarkresult">268</td><td class="benchmarkresult">282</td><td class="benchmarkresult">594</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L77">Concat email stringzilla concat</a><span class="tooltiptext code">sz::string email_concat_stringzilla_exp(sz::string name, sz::string_view domain, sz::string_view tld) {
|
||
return sz::string{name | sz::string_view{"@"} | domain | sz::string_view{"."} | tld};
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">В stringzilla тоже есть конкатенация строковыми выражениями, но не
|
||
так удобна и развита, как в simstr.
|
||
Stringzilla also has concatenation by expression templates,
|
||
but it's not as convenient or advanced as simstr.</span></span></td><td class="benchmarkresult">54.9</td><td class="benchmarkresult">48.3</td><td class="benchmarkresult">126</td><td class="benchmarkresult">131</td><td class="benchmarkresult">213</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L126">Concat email std::string append</a><span class="tooltiptext code">std::string email_concat_std(std::string name, std::string_view domain, std::string_view tld) {
|
||
return name.append("@").append(domain).append(".").append(tld);
|
||
}</span></span></td><td></td><td class="benchmarkresult">72.1</td><td class="benchmarkresult">96.7</td><td class="benchmarkresult">189</td><td class="benchmarkresult">198</td><td class="benchmarkresult">623</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L142">Concat email std::string by strexpr</a><span class="tooltiptext code">std::string email_concat_std_expr(std::string_view name, std::string_view domain, std::string_view tld) {
|
||
return +name + "@" + domain + "." + tld;
|
||
}</span></span></td><td></td><td class="benchmarkresult">44.3</td><td class="benchmarkresult">33.5</td><td class="benchmarkresult">108</td><td class="benchmarkresult">106</td><td class="benchmarkresult">158</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L157">Concat email stringa</a><span class="tooltiptext code">stringa email_concat_sim_expr(ssa name, ssa domain, ssa tld) {
|
||
return name + "@" + domain + "." + tld;
|
||
}</span></span></td><td></td><td class="benchmarkresult">39.9</td><td class="benchmarkresult">40.3</td><td class="benchmarkresult">92.7</td><td class="benchmarkresult">103</td><td class="benchmarkresult">124</td></tr>
|
||
</tbody></table></div><script>bench_sets['Concatenate email'] = {id:'bs1', tests:[
|
||
{name:'Concat email std::format',data:[163,177,203,259,964]},
|
||
{name:'Concat email std::stringstream',data:[322,328,792,898,2458]},
|
||
{name:'Concat email stringzilla append',data:[133,115,268,282,594]},
|
||
{name:'Concat email stringzilla concat',data:[54.9,48.3,126,131,213]},
|
||
{name:'Concat email std::string append',data:[72.1,96.7,189,198,623]},
|
||
{name:'Concat email std::string by strexpr',data:[44.3,33.5,108,106,158]},
|
||
{name:'Concat email stringa',data:[39.9,40.3,92.7,103,124]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs2"><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 Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L181">Concat std::string and number by std to std::string</a><span class="tooltiptext code">void ConcatStdToStd(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">214</td><td class="benchmarkresult">224</td><td class="benchmarkresult">273</td><td class="benchmarkresult">320</td><td class="benchmarkresult">1831</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L192">Concat std::string and number by StrExpr to std::string</a><span class="tooltiptext code">void ConcatSimToStd(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">103</td><td class="benchmarkresult">100</td><td class="benchmarkresult">152</td><td class="benchmarkresult">212</td><td class="benchmarkresult">947</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L203">Concat stringa and number by StrExpr to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSim(benchmark::State& state) {
|
||
stra s1 = "start ";
|
||
for (auto _: state) {
|
||
for (int i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
stringa str = s1 + i + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">stringa в отличии от std::string,
|
||
вмещает в SSO 23 символа вместо 15, поэтому
|
||
в конце теста std::string приходится аллоцировать память,
|
||
а в stringa весь тест входит в SSO.
|
||
Unlike std::string, stringa
|
||
holds 23 characters in SSO instead of 15, so
|
||
at the end of the std::string test, memory has to be allocated,
|
||
while in stringa , the entire test is included in SSO.</span></span></td><td class="benchmarkresult">63.0</td><td class="benchmarkresult">72.8</td><td class="benchmarkresult">70.1</td><td class="benchmarkresult">107</td><td class="benchmarkresult">354</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L214">Concat stringa and number by e_concat to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSimConcat(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">67.4</td><td class="benchmarkresult">75.7</td><td class="benchmarkresult">74.4</td><td class="benchmarkresult">115</td><td class="benchmarkresult">377</td></tr>
|
||
</tbody></table></div><script>bench_sets['Concatenate string + Number + "Literal"'] = {id:'bs2', tests:[
|
||
{name:'Concat std::string and number by std to std::string',data:[214,224,273,320,1831]},
|
||
{name:'Concat std::string and number by StrExpr to std::string',data:[103,100,152,212,947]},
|
||
{name:'Concat stringa and number by StrExpr to simstr::stringa',data:[63.0,72.8,70.1,107,354]},
|
||
{name:'Concat stringa and number by e_concat to simstr::stringa',data:[67.4,75.7,74.4,115,377]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs3"><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 Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L231">Concat std::string and format hex number and literal to std::string</a><span class="tooltiptext code">void ConcatStdToFmtHex(benchmark::State& state) {
|
||
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
|
||
std::string s1 = "art ";
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
// It is not worked for char8_t, char16_t, char32_t :(
|
||
std::string str = s1 + std::format("{:#x}", i) + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">654</td><td class="benchmarkresult">712</td><td class="benchmarkresult">705</td><td class="benchmarkresult">1044</td><td class="benchmarkresult">3883</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L244">std::format std::string and hex number by literal to std::string</a><span class="tooltiptext code">void ConcatAllFmtToHex(benchmark::State& state) {
|
||
// We use a short string so that the longest result is 15 characters and fits in the std::string SSO buffer.
|
||
std::string s1 = "art ";
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
// It is not worked for char8_t, char16_t, char32_t :(
|
||
std::string str = std::format("{}{:#x} end", s1, i);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">874</td><td class="benchmarkresult">969</td><td class="benchmarkresult">1462</td><td class="benchmarkresult">1832</td><td class="benchmarkresult">4986</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L256">Concat std::string and std::to_chars and string to std::string</a><span class="tooltiptext code">void ConcatStdToCharsHex(benchmark::State& state) {
|
||
// 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 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";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">196</td><td class="benchmarkresult">252</td><td class="benchmarkresult">189</td><td class="benchmarkresult">253</td><td class="benchmarkresult">1124</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L271">Concat std::string and hex number and literal by StrExpr to std::string</a><span class="tooltiptext code">void ConcatSimToStdHex(benchmark::State& state) {
|
||
// 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);
|
||
// Can work for all types of symbols
|
||
std::string str = +s1 + i / 1_f16 + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">131</td><td class="benchmarkresult">124</td><td class="benchmarkresult">87.4</td><td class="benchmarkresult">115</td><td class="benchmarkresult">873</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L284">Concat stringa and hex number and literal by StrExpr to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSimHex(benchmark::State& state) {
|
||
// 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);
|
||
// Can work for all types of symbols
|
||
stringa str = s1 + i / 1_f16 + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">115</td><td class="benchmarkresult">120</td><td class="benchmarkresult">77.7</td><td class="benchmarkresult">99.3</td><td class="benchmarkresult">257</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L297">Concat stringa and hex number and literal by e_concat to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSimHexC(benchmark::State& state) {
|
||
// 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);
|
||
// Can work for all types of symbols
|
||
stringa str = e_concat("", s1, i / 1_f16, " end");
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">122</td><td class="benchmarkresult">126</td><td class="benchmarkresult">76.3</td><td class="benchmarkresult">106</td><td class="benchmarkresult">269</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L310">Subst stringa and hex number by e_subst literal to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSimHexS(benchmark::State& state) {
|
||
// stringa SSO buffer is 23, but we use a short string to compare under the same conditions
|
||
stra s1 = "art ";
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
stringa str = e_subst("{}{} end", s1, i / 1_f16);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">180</td><td class="benchmarkresult">164</td><td class="benchmarkresult">152</td><td class="benchmarkresult">171</td><td class="benchmarkresult">541</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L322">Subst stringa and hex number by e_vsubst stra to simstr::stringa</a><span class="tooltiptext code">void ConcatSimToSimHexVS(benchmark::State& state) {
|
||
// 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, i / 1_f16);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">313</td><td class="benchmarkresult">302</td><td class="benchmarkresult">279</td><td class="benchmarkresult">356</td><td class="benchmarkresult">1765</td></tr>
|
||
</tbody></table></div><script>bench_sets['Concatenate string + Hex Number + "Literal"'] = {id:'bs3', tests:[
|
||
{name:'Concat std::string and format hex number and literal to std::string',data:[654,712,705,1044,3883]},
|
||
{name:'std::format std::string and hex number by literal to std::string',data:[874,969,1462,1832,4986]},
|
||
{name:'Concat std::string and std::to_chars and string to std::string',data:[196,252,189,253,1124]},
|
||
{name:'Concat std::string and hex number and literal by StrExpr to std::string',data:[131,124,87.4,115,873]},
|
||
{name:'Concat stringa and hex number and literal by StrExpr to simstr::stringa',data:[115,120,77.7,99.3,257]},
|
||
{name:'Concat stringa and hex number and literal by e_concat to simstr::stringa',data:[122,126,76.3,106,269]},
|
||
{name:'Subst stringa and hex number by e_subst literal to simstr::stringa',data:[180,164,152,171,541]},
|
||
{name:'Subst stringa and hex number by e_vsubst stra to simstr::stringa',data:[313,302,279,356,1765]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs4"><h4><a id="bs32341904136562619220" href="#bs32341904136562619220">#</a> format/vformat and subst/vsubst octal number to 32 symbols result</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L344">"abcdefghihklmopqr "_ss + i / 0x8a010_fmt + " end"</a><span class="tooltiptext code">void ConcatSimToSimOct(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
stringa str = "abcdefghihklmopqr "_ss + i / 0x8a010_fmt + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">280</td><td class="benchmarkresult">266</td><td class="benchmarkresult">660</td><td class="benchmarkresult">698</td><td class="benchmarkresult">843</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L353">e_subst("abcdefghihklmopqr {} end", i / 0x8a010_fmt)</a><span class="tooltiptext code">void SubstSimToSimOct(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
stringa str = e_subst("abcdefghihklmopqr {} end", i / 0x8a010_fmt);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">341</td><td class="benchmarkresult">324</td><td class="benchmarkresult">778</td><td class="benchmarkresult">813</td><td class="benchmarkresult">1112</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L362">e_vsubst(pattern, i / 0x8a010_fmt)</a><span class="tooltiptext code">void VSubstSimToSimOct(benchmark::State& state) {
|
||
ssa pattern = "abcdefghihklmopqr {} end";
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
stringa str = e_vsubst(pattern, i / 0x8a010_fmt);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">599</td><td class="benchmarkresult">583</td><td class="benchmarkresult">1061</td><td class="benchmarkresult">1118</td><td class="benchmarkresult">2885</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L402">fmt::format(FMT_COMPILE("abcdefghihklmopqr {:#010o} end"), i)</a><span class="tooltiptext code">void FmtFormatComp(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
std::string str = fmt::format(FMT_COMPILE("abcdefghihklmopqr {:#010o} end"), i);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">676</td><td class="benchmarkresult">785</td><td class="benchmarkresult">1404</td><td class="benchmarkresult">1550</td><td class="benchmarkresult">4562</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L411">fmt::format("abcdefghihklmopqr {:#010o} end", i)</a><span class="tooltiptext code">void FmtFormat(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
std::string str = fmt::format("abcdefghihklmopqr {:#010o} end", i);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
|
||
}</span></span></td><td></td><td class="benchmarkresult">832</td><td class="benchmarkresult">827</td><td class="benchmarkresult">1355</td><td class="benchmarkresult">1431</td><td class="benchmarkresult">4550</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L372">std::format("abcdefghihklmopqr {:#010o} end", i)</a><span class="tooltiptext code">void FormatStdToStdOct(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
std::string str = std::format("abcdefghihklmopqr {:#010o} end", i);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1007</td><td class="benchmarkresult">1224</td><td class="benchmarkresult">1542</td><td class="benchmarkresult">1923</td><td class="benchmarkresult">5661</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L381">std::vformat(pattern, std::make_format_args(i))</a><span class="tooltiptext code">void VFormatStdToStdOct(benchmark::State& state) {
|
||
std::string_view pattern = "abcdefghihklmopqr {:#010o} end";
|
||
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">1001</td><td class="benchmarkresult">1100</td><td class="benchmarkresult">1549</td><td class="benchmarkresult">1941</td><td class="benchmarkresult">5730</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L391">strm << "abcdefghihklmopqr 0" << std::oct << std::setw(9) << std::setfill('0') << i << " end"</a><span class="tooltiptext code">void StreamStdToStdOct(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||
std::stringstream strm;
|
||
strm << "abcdefghihklmopqr 0" << std::oct << std::setw(9) << std::setfill('0') << i << " end";
|
||
std::string str = strm.str();
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">2029</td><td class="benchmarkresult">2121</td><td class="benchmarkresult">6785</td><td class="benchmarkresult">7038</td><td class="benchmarkresult">19623</td></tr>
|
||
</tbody></table></div><script>bench_sets['format/vformat and subst/vsubst octal number to 32 symbols result'] = {id:'bs4', tests:[
|
||
{name:'"abcdefghihklmopqr "_ss + i / 0x8a010_fmt + " end"',data:[280,266,660,698,843]},
|
||
{name:'e_subst("abcdefghihklmopqr {} end", i / 0x8a010_fmt)',data:[341,324,778,813,1112]},
|
||
{name:'e_vsubst(pattern, i / 0x8a010_fmt)',data:[599,583,1061,1118,2885]},
|
||
{name:'fmt::format(FMT_COMPILE("abcdefghihklmopqr {:#010o} end"), i)',data:[676,785,1404,1550,4562]},
|
||
{name:'fmt::format("abcdefghihklmopqr {:#010o} end", i)',data:[832,827,1355,1431,4550]},
|
||
{name:'std::format("abcdefghihklmopqr {:#010o} end", i)',data:[1007,1224,1542,1923,5661]},
|
||
{name:'std::vformat(pattern, std::make_format_args(i))',data:[1001,1100,1549,1941,5730]},
|
||
{name:'strm << "abcdefghihklmopqr 0" << std::oct << std::setw(9) << std::setfill(\'0\') << i << " end"',data:[2029,2121,6785,7038,19623]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs5"><h4><a id="bs59672599204338055190" href="#bs59672599204338055190">#</a> Concatenate string + "Literal"</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L431">Concat std::string by std to std::string</a><span class="tooltiptext code">void ConcatStdToStdS(benchmark::State& state) {
|
||
std::string s1 = "start ";
|
||
for (auto _: state) {
|
||
for (int i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
std::string str = s1 + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">49.0</td><td class="benchmarkresult">52.3</td><td class="benchmarkresult">41.5</td><td class="benchmarkresult">55.6</td><td class="benchmarkresult">143</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L442">Concat std::string by StrExpr to std::string</a><span class="tooltiptext code">void ConcatSimToStdS(benchmark::State& state) {
|
||
std::string s1 = "start ";
|
||
for (auto _: state) {
|
||
for (int i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
std::string str = +s1 + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">39.9</td><td class="benchmarkresult">34.1</td><td class="benchmarkresult">38.6</td><td class="benchmarkresult">81.8</td><td class="benchmarkresult">168</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L453">Concat stringa by StrExpr to stringa</a><span class="tooltiptext code">void ConcatSimToSimS(benchmark::State& state) {
|
||
stra s1 = "start ";
|
||
for (auto _: state) {
|
||
for (int i = 1; i <= 100'000; i *= 10) {
|
||
benchmark::DoNotOptimize(s1);
|
||
stringa str = s1 + " end";
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">27.1</td><td class="benchmarkresult">27.5</td><td class="benchmarkresult">28.7</td><td class="benchmarkresult">50.8</td><td class="benchmarkresult">136</td></tr>
|
||
</tbody></table></div><script>bench_sets['Concatenate string + "Literal"'] = {id:'bs5', tests:[
|
||
{name:'Concat std::string by std to std::string',data:[49.0,52.3,41.5,55.6,143]},
|
||
{name:'Concat std::string by StrExpr to std::string',data:[39.9,34.1,38.6,81.8,168]},
|
||
{name:'Concat stringa by StrExpr to stringa',data:[27.1,27.5,28.7,50.8,136]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs6"><h4><a id="bs68116594352702954700" href="#bs68116594352702954700">#</a> Find three concatenated string in string_view</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L469">Find concat three std::string</a><span class="tooltiptext code">size_t find_pos_str(std::string_view src, std::string_view name) {
|
||
// before C++26 we can not concatenate string and string_view...
|
||
return src.find("\n- "s + std::string{name} + " -\n");
|
||
}</span></span></td><td></td><td class="benchmarkresult">110</td><td class="benchmarkresult">137</td><td class="benchmarkresult">205</td><td class="benchmarkresult">228</td><td class="benchmarkresult">542</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L474">Find concat three strexpr</a><span class="tooltiptext code">size_t find_pos_exp(ssa src, ssa name) {
|
||
return src.find(std::string{"\n- " + name + " -\n"});
|
||
}</span></span></td><td></td><td class="benchmarkresult">51.5</td><td class="benchmarkresult">38.1</td><td class="benchmarkresult">118</td><td class="benchmarkresult">132</td><td class="benchmarkresult">294</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L478">Find concat three simstr</a><span class="tooltiptext code">size_t find_pos_sim(ssa src, ssa name) {
|
||
return src.find(lstringa<200>{"\n- " + name + " -\n"});
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Если результат конкатенации меньше 207 символов,
|
||
он собирается в буфере на стеке, без аллокации и деалокации.
|
||
If the concatenation result is less than 207 characters,
|
||
it is collected in a stack-based buffer, without allocation or deallocation.</span></span></td><td class="benchmarkresult">19.4</td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">27.2</td><td class="benchmarkresult">29.2</td><td class="benchmarkresult">174</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L482">Find concat three stringzilla string</a><span class="tooltiptext code">size_t find_pos_sz(sz::string_view src, sz::string_view name) {
|
||
return src.find(sz::string{"\n- "}.append(name).append(" -\n"));
|
||
}</span></span></td><td></td><td class="benchmarkresult">146</td><td class="benchmarkresult">150</td><td class="benchmarkresult">215</td><td class="benchmarkresult">228</td><td class="benchmarkresult">619</td></tr>
|
||
</tbody></table></div><script>bench_sets['Find three concatenated string in string_view'] = {id:'bs6', tests:[
|
||
{name:'Find concat three std::string',data:[110,137,205,228,542]},
|
||
{name:'Find concat three strexpr',data:[51.5,38.1,118,132,294]},
|
||
{name:'Find concat three simstr',data:[19.4,15.9,27.2,29.2,174]},
|
||
{name:'Find concat three stringzilla string',data:[146,150,215,228,619]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs7"><h4><a id="bs145290966789248325200" href="#bs145290966789248325200">#</a> Build Type Name</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L558">BuildTypeNameStr 0/0</a><span class="tooltiptext code">std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
|
||
std::string res{type_name};
|
||
if (prec) {
|
||
res += "(" + std::to_string(prec);
|
||
if (scale) {
|
||
res += "," + std::to_string(scale);
|
||
}
|
||
res += ")";
|
||
}
|
||
return res;
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.65</td><td class="benchmarkresult">10.1</td><td class="benchmarkresult">8.48</td><td class="benchmarkresult">18.1</td><td class="benchmarkresult">27.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L570">BuildTypeNameExp 0/0</a><span class="tooltiptext code">std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
|
||
if (prec) {
|
||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||
}
|
||
return type_name;
|
||
}</span></span></td><td></td><td class="benchmarkresult">6.50</td><td class="benchmarkresult">8.75</td><td class="benchmarkresult">7.64</td><td class="benchmarkresult">14.5</td><td class="benchmarkresult">28.9</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L577">BuildTypeNameSim 0/0</a><span class="tooltiptext code">stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
|
||
if (prec) {
|
||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||
}
|
||
return type_name;
|
||
}</span></span></td><td></td><td class="benchmarkresult">4.14</td><td class="benchmarkresult">4.90</td><td class="benchmarkresult">7.75</td><td class="benchmarkresult">16.3</td><td class="benchmarkresult">38.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L558">BuildTypeNameStr 10/10</a><span class="tooltiptext code">std::string buildTypeNameStr(std::string_view type_name, size_t prec, size_t scale) {
|
||
std::string res{type_name};
|
||
if (prec) {
|
||
res += "(" + std::to_string(prec);
|
||
if (scale) {
|
||
res += "," + std::to_string(scale);
|
||
}
|
||
res += ")";
|
||
}
|
||
return res;
|
||
}</span></span></td><td></td><td class="benchmarkresult">56.9</td><td class="benchmarkresult">84.3</td><td class="benchmarkresult">59.6</td><td class="benchmarkresult">85.7</td><td class="benchmarkresult">652</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L570">BuildTypeNameExp 10/10</a><span class="tooltiptext code">std::string buildTypeNameExp(ssa type_name, size_t prec, size_t scale) {
|
||
if (prec) {
|
||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||
}
|
||
return type_name;
|
||
}</span></span></td><td></td><td class="benchmarkresult">29.9</td><td class="benchmarkresult">25.9</td><td class="benchmarkresult">33.3</td><td class="benchmarkresult">40.1</td><td class="benchmarkresult">196</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L577">BuildTypeNameSim 10/10</a><span class="tooltiptext code">stringa buildTypeNameSim(ssa type_name, size_t prec, size_t scale) {
|
||
if (prec) {
|
||
return type_name + "(" + prec + e_if(scale, ","_ss + scale) + ")";
|
||
}
|
||
return type_name;
|
||
}</span></span></td><td></td><td class="benchmarkresult">22.9</td><td class="benchmarkresult">23.6</td><td class="benchmarkresult">25.6</td><td class="benchmarkresult">40.1</td><td class="benchmarkresult">141</td></tr>
|
||
</tbody></table></div><script>bench_sets['Build Type Name'] = {id:'bs7', tests:[
|
||
{name:'BuildTypeNameStr 0/0',data:[7.65,10.1,8.48,18.1,27.4]},
|
||
{name:'BuildTypeNameExp 0/0',data:[6.50,8.75,7.64,14.5,28.9]},
|
||
{name:'BuildTypeNameSim 0/0',data:[4.14,4.90,7.75,16.3,38.4]},
|
||
{name:'BuildTypeNameStr 10/10',data:[56.9,84.3,59.6,85.7,652]},
|
||
{name:'BuildTypeNameExp 10/10',data:[29.9,25.9,33.3,40.1,196]},
|
||
{name:'BuildTypeNameSim 10/10',data:[22.9,23.6,25.6,40.1,141]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs8"><h4><a id="bs54035654251116789780" href="#bs54035654251116789780">#</a> Replace string by copy</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L631">Concat with replace str</a><span class="tooltiptext code">std::string make_str_str(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||
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) + ">";
|
||
}</span></span></td><td></td><td class="benchmarkresult">200</td><td class="benchmarkresult">250</td><td class="benchmarkresult">308</td><td class="benchmarkresult">366</td><td class="benchmarkresult">1074</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L649">Concat with replace exp</a><span class="tooltiptext code">std::string make_str_exp(std::string_view from, std::string_view pattern, std::string_view repl) {
|
||
return "<" + e_repl(from, pattern, repl) + ">";
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">В simstr строковое выражение для замены подстрок
|
||
есть "из коробки".
|
||
simstr has a string expression for replacing substrings out of the box.</span></span></td><td class="benchmarkresult">147</td><td class="benchmarkresult">133</td><td class="benchmarkresult">222</td><td class="benchmarkresult">221</td><td class="benchmarkresult">519</td></tr>
|
||
</tbody></table></div><script>bench_sets['Replace string by copy'] = {id:'bs8', tests:[
|
||
{name:'Concat with replace str',data:[200,250,308,366,1074]},
|
||
{name:'Concat with replace exp',data:[147,133,222,221,519]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs9"><h4><a id="bs77666948964429305550" href="#bs77666948964429305550">#</a> Create Empty Str</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">std::string e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Пустые строки, ничего необычного.
|
||
Empty lines, nothing unusual.</span></span></td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.09</td><td class="benchmarkresult">1.14</td><td class="benchmarkresult">3.25</td><td class="benchmarkresult">2.60</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">std::string_view e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.375</td><td class="benchmarkresult">0.739</td><td class="benchmarkresult">0.372</td><td class="benchmarkresult">1.85</td><td class="benchmarkresult">2.15</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">ssa e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.361</td><td class="benchmarkresult">0.183</td><td class="benchmarkresult">0.359</td><td class="benchmarkresult">1.45</td><td class="benchmarkresult">2.16</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">stringa e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.753</td><td class="benchmarkresult">0.731</td><td class="benchmarkresult">0.736</td><td class="benchmarkresult">2.20</td><td class="benchmarkresult">5.52</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">lstringa<20> e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1.20</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">2.59</td><td class="benchmarkresult">9.16</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L683">lstringa<40> e;</a><span class="tooltiptext code">template<typename T>
|
||
void CreateEmpty(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1.13</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.10</td><td class="benchmarkresult">2.62</td><td class="benchmarkresult">8.53</td></tr>
|
||
</tbody></table></div><script>bench_sets['Create Empty Str'] = {id:'bs9', tests:[
|
||
{name:'std::string e;',data:[1.11,1.09,1.14,3.25,2.60]},
|
||
{name:'std::string_view e;',data:[0.375,0.739,0.372,1.85,2.15]},
|
||
{name:'ssa e;',data:[0.361,0.183,0.359,1.45,2.16]},
|
||
{name:'stringa e;',data:[0.753,0.731,0.736,2.20,5.52]},
|
||
{name:'lstringa<20> e;',data:[1.20,1.11,1.11,2.59,9.16]},
|
||
{name:'lstringa<40> e;',data:[1.13,1.11,1.10,2.62,8.53]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs10"><h4><a id="bs181001525395597238060" href="#bs181001525395597238060">#</a> Create Str from short literal (9 symbols)</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">std::string e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Короткий литерал помещается во внутренний буфер std::string,
|
||
время тратится только на копирование 10 байтов.
|
||
The short literal is placed in the internal std::string buffer;
|
||
time is spent only copying 10 bytes.</span></span></td><td class="benchmarkresult">1.81</td><td class="benchmarkresult">1.84</td><td class="benchmarkresult">1.81</td><td class="benchmarkresult">2.67</td><td class="benchmarkresult">10.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">std::string_view e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">И string_view, и ssa - по сути одно и то же:
|
||
указатель на текст и его длина.
|
||
Both string_view and ssa are essentially the same thing:
|
||
a pointer to text and its length.</span></span></td><td class="benchmarkresult">0.731</td><td class="benchmarkresult">0.736</td><td class="benchmarkresult">0.734</td><td class="benchmarkresult">1.84</td><td class="benchmarkresult">2.18</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">ssa e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.367</td><td class="benchmarkresult">0.750</td><td class="benchmarkresult">0.364</td><td class="benchmarkresult">1.87</td><td class="benchmarkresult">2.17</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">stringa e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">stringa при инициализации константным литералом так же
|
||
сохраняет только указатель на текст и его длину.
|
||
When initialized with a constant literal, stringa also stores
|
||
only a pointer to the text and its length.</span></span></td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">2.86</td><td class="benchmarkresult">8.30</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">lstringa<20> e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Внутреннего буфера хватает для размещения символов,
|
||
время уходит только на копирование байтов.
|
||
The internal buffer is sufficient to accommodate characters;
|
||
time is spent only on copying bytes.</span></span></td><td class="benchmarkresult">1.85</td><td class="benchmarkresult">1.84</td><td class="benchmarkresult">1.87</td><td class="benchmarkresult">2.55</td><td class="benchmarkresult">3.89</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L698">lstringa<40> e = "Test text";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateShortLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string = TEST_TEXT;
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1.88</td><td class="benchmarkresult">1.84</td><td class="benchmarkresult">1.94</td><td class="benchmarkresult">2.53</td><td class="benchmarkresult">3.93</td></tr>
|
||
</tbody></table></div><script>bench_sets['Create Str from short literal (9 symbols)'] = {id:'bs10', tests:[
|
||
{name:'std::string e = "Test text";',data:[1.81,1.84,1.81,2.67,10.4]},
|
||
{name:'std::string_view e = "Test text";',data:[0.731,0.736,0.734,1.84,2.18]},
|
||
{name:'ssa e = "Test text";',data:[0.367,0.750,0.364,1.87,2.17]},
|
||
{name:'stringa e = "Test text";',data:[1.11,1.11,1.11,2.86,8.30]},
|
||
{name:'lstringa<20> e = "Test text";',data:[1.85,1.84,1.87,2.55,3.89]},
|
||
{name:'lstringa<40> e = "Test text";',data:[1.88,1.84,1.94,2.53,3.93]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs11"><h4><a id="bs132333183298742730280" href="#bs132333183298742730280">#</a> Create Str from long literal (30 symbols)</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">std::string e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Вот тут уже литерал не помещается во внутренний буфер,
|
||
возникает аллокация и копирование 30-и байтов.
|
||
Но как же отстает аллокация под Windows от Linux'а, 20 vs 70 ns...
|
||
Here, the literal doesn't fit into the internal buffer,
|
||
and 30 bytes are allocated and copied.
|
||
But how much slower is allocation under Windows than under Linux, 20 ns vs. 70 ns...</span></span></td><td class="benchmarkresult">19.1</td><td class="benchmarkresult">19.2</td><td class="benchmarkresult">73.4</td><td class="benchmarkresult">73.6</td><td class="benchmarkresult">68.6</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">std::string_view e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">string_view и ssa по прежнему ничего не делают, кроме
|
||
запоминания указателя на текст и его размера.
|
||
string_view and ssa still do nothing except
|
||
remember the pointer to the text and its size.</span></span></td><td class="benchmarkresult">0.762</td><td class="benchmarkresult">0.752</td><td class="benchmarkresult">0.750</td><td class="benchmarkresult">1.83</td><td class="benchmarkresult">2.19</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">ssa e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.369</td><td class="benchmarkresult">0.733</td><td class="benchmarkresult">0.360</td><td class="benchmarkresult">1.81</td><td class="benchmarkresult">2.18</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">stringa e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">stringa на константных литералах не отстает!
|
||
stringa doesn't lag behind on constant literals!</span></span></td><td class="benchmarkresult">1.09</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.08</td><td class="benchmarkresult">2.54</td><td class="benchmarkresult">8.30</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">lstringa<20> e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">lstringa<20> может вместить в себя до 23 символов,
|
||
Очевидно, что для 30-и символов уже нужна аллокация.
|
||
Obviously, 30 characters already require allocation.</span></span></td><td class="benchmarkresult">21.0</td><td class="benchmarkresult">20.4</td><td class="benchmarkresult">73.6</td><td class="benchmarkresult">75.1</td><td class="benchmarkresult">68.6</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L713">lstringa<40> e = "123456789012345678901234567890";</a><span class="tooltiptext code">template<typename T>
|
||
void CreateLongLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
T empty_string{LONG_TEXT};
|
||
benchmark::DoNotOptimize(empty_string);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А в lstringa<40> влезает до 47 символов, так что просто
|
||
копируется 30 байтов.
|
||
And lstringa<40> can hold up to 47 characters, so 30
|
||
bytes are simply copied.</span></span></td><td class="benchmarkresult">2.54</td><td class="benchmarkresult">1.82</td><td class="benchmarkresult">2.50</td><td class="benchmarkresult">3.27</td><td class="benchmarkresult">11.4</td></tr>
|
||
</tbody></table></div><script>bench_sets['Create Str from long literal (30 symbols)'] = {id:'bs11', tests:[
|
||
{name:'std::string e = "123456789012345678901234567890";',data:[19.1,19.2,73.4,73.6,68.6]},
|
||
{name:'std::string_view e = "123456789012345678901234567890";',data:[0.762,0.752,0.750,1.83,2.19]},
|
||
{name:'ssa e = "123456789012345678901234567890";',data:[0.369,0.733,0.360,1.81,2.18]},
|
||
{name:'stringa e = "123456789012345678901234567890";',data:[1.09,1.11,1.08,2.54,8.30]},
|
||
{name:'lstringa<20> e = "123456789012345678901234567890";',data:[21.0,20.4,73.6,75.1,68.6]},
|
||
{name:'lstringa<40> e = "123456789012345678901234567890";',data:[2.54,1.82,2.50,3.27,11.4]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs12"><h4><a id="bs6234433963744178700" href="#bs6234433963744178700">#</a> Create copy of Str with 9 symbols</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">std::string e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Строка в пределах SSO, так что просто копирует байты.
|
||
The string is within the SSO, so it just copies the bytes.</span></span></td><td class="benchmarkresult">5.58</td><td class="benchmarkresult">5.62</td><td class="benchmarkresult">1.82</td><td class="benchmarkresult">5.10</td><td class="benchmarkresult">7.32</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">std::string_view e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.370</td><td class="benchmarkresult">0.365</td><td class="benchmarkresult">0.363</td><td class="benchmarkresult">3.79</td><td class="benchmarkresult">2.17</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">ssa e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">ssa и string_view не владеют строкой, копируется
|
||
только информация о строке.
|
||
ssa and string_view don't own the string; only the
|
||
string information is copied.</span></span></td><td class="benchmarkresult">0.372</td><td class="benchmarkresult">0.374</td><td class="benchmarkresult">0.366</td><td class="benchmarkresult">3.85</td><td class="benchmarkresult">2.18</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">stringa e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Копирование stringa происходит быстро,
|
||
особенно если она инициализирована литералом.
|
||
Copying a stringa is fast,
|
||
especially if it is initialized with a literal.</span></span></td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.28</td><td class="benchmarkresult">4.00</td><td class="benchmarkresult">6.33</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">lstringa<20> e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">В обоих случаях хватает внутреннего буфера.
|
||
In both cases, the internal buffer is sufficient.</span></span></td><td class="benchmarkresult">1.49</td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.50</td><td class="benchmarkresult">4.38</td><td class="benchmarkresult">7.15</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L728">lstringa<40> e = "Test text"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyShortString(benchmark::State& state) {
|
||
T x{TEST_TEXT};
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Только копируются байты.
|
||
Only bytes are copied.</span></span></td><td class="benchmarkresult">1.48</td><td class="benchmarkresult">1.13</td><td class="benchmarkresult">1.47</td><td class="benchmarkresult">4.52</td><td class="benchmarkresult">7.33</td></tr>
|
||
</tbody></table></div><script>bench_sets['Create copy of Str with 9 symbols'] = {id:'bs12', tests:[
|
||
{name:'std::string e = "Test text"; auto c{e};',data:[5.58,5.62,1.82,5.10,7.32]},
|
||
{name:'std::string_view e = "Test text"; auto c{e};',data:[0.370,0.365,0.363,3.79,2.17]},
|
||
{name:'ssa e = "Test text"; auto c{e};',data:[0.372,0.374,0.366,3.85,2.18]},
|
||
{name:'stringa e = "Test text"; auto c{e};',data:[1.11,1.11,1.28,4.00,6.33]},
|
||
{name:'lstringa<20> e = "Test text"; auto c{e};',data:[1.49,1.11,1.50,4.38,7.15]},
|
||
{name:'lstringa<40> e = "Test text"; auto c{e};',data:[1.48,1.13,1.47,4.52,7.33]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs13"><h4><a id="bs76384575499199461500" href="#bs76384575499199461500">#</a> Create copy of Str with 30 symbols</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">std::string e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Копирования длинной строки вызывает аллокацию,
|
||
SSO уже не хватает. И снова как же отстаёт аллокация под Windows...
|
||
Copying a long string causes allocations,
|
||
SSO is no longer sufficient. And again, how allocation lags under Windows...</span></span></td><td class="benchmarkresult">19.0</td><td class="benchmarkresult">23.8</td><td class="benchmarkresult">75.8</td><td class="benchmarkresult">78.3</td><td class="benchmarkresult">120</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">std::string_view e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.761</td><td class="benchmarkresult">0.735</td><td class="benchmarkresult">0.735</td><td class="benchmarkresult">1.85</td><td class="benchmarkresult">2.22</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">ssa e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">0.366</td><td class="benchmarkresult">0.742</td><td class="benchmarkresult">0.361</td><td class="benchmarkresult">1.81</td><td class="benchmarkresult">2.16</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">stringa e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А вот у stringa копирование литерала не зависит от его длины,
|
||
сравни с предыдущим бенчмарком.
|
||
But with stringa, literal copying doesn't depend on its length,
|
||
compare with the previous benchmark.</span></span></td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.30</td><td class="benchmarkresult">1.82</td><td class="benchmarkresult">2.93</td><td class="benchmarkresult">8.35</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">lstringa<20> e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Не влезает, аллокация.
|
||
Doesn't fit, allocation.</span></span></td><td class="benchmarkresult">21.0</td><td class="benchmarkresult">19.8</td><td class="benchmarkresult">75.1</td><td class="benchmarkresult">82.0</td><td class="benchmarkresult">67.2</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L745">lstringa<40> e = "123456789012345678901234567890"; auto c{e};</a><span class="tooltiptext code">template<typename T>
|
||
void CopyLongString(benchmark::State& state) {
|
||
T x = LONG_TEXT;
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Уложили во внутренний буфер.
|
||
Placed in the internal buffer.</span></span></td><td class="benchmarkresult">4.83</td><td class="benchmarkresult">4.67</td><td class="benchmarkresult">4.73</td><td class="benchmarkresult">7.56</td><td class="benchmarkresult">19.7</td></tr>
|
||
</tbody></table></div><script>bench_sets['Create copy of Str with 30 symbols'] = {id:'bs13', tests:[
|
||
{name:'std::string e = "123456789012345678901234567890"; auto c{e};',data:[19.0,23.8,75.8,78.3,120]},
|
||
{name:'std::string_view e = "123456789012345678901234567890"; auto c{e};',data:[0.761,0.735,0.735,1.85,2.22]},
|
||
{name:'ssa e = "123456789012345678901234567890"; auto c{e};',data:[0.366,0.742,0.361,1.81,2.16]},
|
||
{name:'stringa e = "123456789012345678901234567890"; auto c{e};',data:[1.11,1.30,1.82,2.93,8.35]},
|
||
{name:'lstringa<20> e = "123456789012345678901234567890"; auto c{e};',data:[21.0,19.8,75.1,82.0,67.2]},
|
||
{name:'lstringa<40> e = "123456789012345678901234567890"; auto c{e};',data:[4.83,4.67,4.73,7.56,19.7]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs14"><h4><a id="bs21623892135774528620" href="#bs21623892135774528620">#</a> Find 9 symbols text in end of 99 symbols text</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">sz::string::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">stringzilla более заточена на поиск больших строк в больших строках.
|
||
stringzilla is more focused on searching large strings within large strings.</span></span></td><td class="benchmarkresult">93.4</td><td class="benchmarkresult">93.8</td><td class="benchmarkresult">98.8</td><td class="benchmarkresult">115</td><td class="benchmarkresult">227</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">std::string::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Здесь "победила дружба", у всех типов по колонке примерно одинаково.
|
||
Однако, Windows и Linux явно в разных весовых категориях.
|
||
Here, "friendship wins," with all types scoring roughly equally.
|
||
However, Windows and Linux are clearly in different weight classes.</span></span></td><td class="benchmarkresult">7.54</td><td class="benchmarkresult">7.67</td><td class="benchmarkresult">39.3</td><td class="benchmarkresult">39.0</td><td class="benchmarkresult">99.1</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">std::string_view::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">6.70</td><td class="benchmarkresult">7.48</td><td class="benchmarkresult">52.1</td><td class="benchmarkresult">40.1</td><td class="benchmarkresult">97.5</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">ssa::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.49</td><td class="benchmarkresult">6.78</td><td class="benchmarkresult">19.5</td><td class="benchmarkresult">21.4</td><td class="benchmarkresult">96.3</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">stringa::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.84</td><td class="benchmarkresult">7.17</td><td class="benchmarkresult">18.9</td><td class="benchmarkresult">30.1</td><td class="benchmarkresult">97.2</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">lstringa<20>::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.38</td><td class="benchmarkresult">6.96</td><td class="benchmarkresult">17.6</td><td class="benchmarkresult">22.0</td><td class="benchmarkresult">97.6</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L762">lstringa<40>::find;</a><span class="tooltiptext code">template<typename T>
|
||
void Find(benchmark::State& state) {
|
||
T x{LONG_TEXT LONG_TEXT LONG_TEXT TEST_TEXT};
|
||
for (auto _: state) {
|
||
int i = (int)x.find(TEST_TEXT);
|
||
#ifdef CHECK_RESULT
|
||
if (i != 90) {
|
||
state.SkipWithError("not find?");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(i);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.02</td><td class="benchmarkresult">6.64</td><td class="benchmarkresult">18.2</td><td class="benchmarkresult">20.7</td><td class="benchmarkresult">96.0</td></tr>
|
||
</tbody></table></div><script>bench_sets['Find 9 symbols text in end of 99 symbols text'] = {id:'bs14', tests:[
|
||
{name:'sz::string::find;',data:[93.4,93.8,98.8,115,227]},
|
||
{name:'std::string::find;',data:[7.54,7.67,39.3,39.0,99.1]},
|
||
{name:'std::string_view::find;',data:[6.70,7.48,52.1,40.1,97.5]},
|
||
{name:'ssa::find;',data:[7.49,6.78,19.5,21.4,96.3]},
|
||
{name:'stringa::find;',data:[7.84,7.17,18.9,30.1,97.2]},
|
||
{name:'lstringa<20>::find;',data:[7.38,6.96,17.6,22.0,97.6]},
|
||
{name:'lstringa<40>::find;',data:[7.02,6.64,18.2,20.7,96.0]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs15"><h4><a id="bs170792414351801782640" href="#bs170792414351801782640">#</a> Copy not literal Str with N symbols</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/15</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">4.87</td><td class="benchmarkresult">7.91</td><td class="benchmarkresult">1.83</td><td class="benchmarkresult">4.42</td><td class="benchmarkresult">125</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/16</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Явно виден скачок, где заканчивается SSO и начинается аллокация.
|
||
Обратите внимание, что WASM - 32-битный, и там размер
|
||
SSO у std::string меньше, 10 символов + 0.
|
||
The jump where SSO ends and allocation begins is clearly visible.
|
||
Note that WASM is 32-bit, and the size of the SSO for std::string is
|
||
smaller, as far as I remember: 11 characters + 0.</span></span></td><td class="benchmarkresult">23.2</td><td class="benchmarkresult">26.5</td><td class="benchmarkresult">80.8</td><td class="benchmarkresult">81.3</td><td class="benchmarkresult">123</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/23</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Дальше просто добавляется время на копирование байтов.
|
||
Then the time for copying bytes is simply added.</span></span></td><td class="benchmarkresult">23.5</td><td class="benchmarkresult">27.3</td><td class="benchmarkresult">78.3</td><td class="benchmarkresult">78.6</td><td class="benchmarkresult">128</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/24</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">22.6</td><td class="benchmarkresult">27.7</td><td class="benchmarkresult">78.5</td><td class="benchmarkresult">79.8</td><td class="benchmarkresult">120</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/32</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">22.6</td><td class="benchmarkresult">26.5</td><td class="benchmarkresult">81.8</td><td class="benchmarkresult">83.8</td><td class="benchmarkresult">128</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/64</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">22.3</td><td class="benchmarkresult">26.9</td><td class="benchmarkresult">82.8</td><td class="benchmarkresult">81.7</td><td class="benchmarkresult">131</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/128</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">23.7</td><td class="benchmarkresult">28.9</td><td class="benchmarkresult">82.6</td><td class="benchmarkresult">87.7</td><td class="benchmarkresult">132</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/256</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">24.9</td><td class="benchmarkresult">28.8</td><td class="benchmarkresult">85.0</td><td class="benchmarkresult">88.5</td><td class="benchmarkresult">161</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/512</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">28.5</td><td class="benchmarkresult">33.6</td><td class="benchmarkresult">86.5</td><td class="benchmarkresult">92.7</td><td class="benchmarkresult">149</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/1024</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">34.8</td><td class="benchmarkresult">44.2</td><td class="benchmarkresult">95.3</td><td class="benchmarkresult">97.1</td><td class="benchmarkresult">156</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/2048</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">79.1</td><td class="benchmarkresult">80.3</td><td class="benchmarkresult">133</td><td class="benchmarkresult">129</td><td class="benchmarkresult">206</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">std::string copy{str_with_len_N};/4096</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Чем длиннее строка, тем дольше создаётся копия.
|
||
The longer the string, the longer it takes to create a copy.</span></span></td><td class="benchmarkresult">111</td><td class="benchmarkresult">115</td><td class="benchmarkresult">179</td><td class="benchmarkresult">180</td><td class="benchmarkresult">271</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/15</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Здесь stringa инициализируется не литералом,
|
||
а значит, должна сама хранить символы.
|
||
Here, stringa is not initialized with a literal,
|
||
meaning it must store characters itself.</span></span></td><td class="benchmarkresult">1.09</td><td class="benchmarkresult">1.09</td><td class="benchmarkresult">1.29</td><td class="benchmarkresult">4.00</td><td class="benchmarkresult">4.60</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/16</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Под WASM SSO у stringa составляет 15 символов. Кроме того,
|
||
собиралось без поддержки потоков, поэтому атомарный
|
||
инкремент заменён на обычный, судя по времени.
|
||
Under WASM, stringa has a 15-character SSO. Furthermore,
|
||
it was built without thread support, so the atomic
|
||
increment was replaced with a regular one, judging by the time.</span></span></td><td class="benchmarkresult">1.13</td><td class="benchmarkresult">1.10</td><td class="benchmarkresult">1.32</td><td class="benchmarkresult">4.02</td><td class="benchmarkresult">7.36</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/23</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">SSO в stringa до 23 символов, и даже 23
|
||
копируются быстрее, чем 15 в std::string.
|
||
SSO in stringa is up to 23 characters, and even 23
|
||
copies faster than 15 in std::string.</span></span></td><td class="benchmarkresult">1.11</td><td class="benchmarkresult">1.10</td><td class="benchmarkresult">1.29</td><td class="benchmarkresult">4.10</td><td class="benchmarkresult">7.39</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/24</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Всё, не влезаем в SSO, а значит, используем shared буфер.
|
||
Добавляется время на атомарный инкремент счётчика.
|
||
That's it, we're not using SSO, so we're using a shared buffer.
|
||
Time is added for the atomic counter increment.</span></span></td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">16.1</td><td class="benchmarkresult">15.8</td><td class="benchmarkresult">18.4</td><td class="benchmarkresult">7.35</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/32</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">15.8</td><td class="benchmarkresult">18.4</td><td class="benchmarkresult">7.33</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/64</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">16.1</td><td class="benchmarkresult">15.8</td><td class="benchmarkresult">18.3</td><td class="benchmarkresult">7.37</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/128</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">15.7</td><td class="benchmarkresult">18.4</td><td class="benchmarkresult">7.30</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/256</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">15.8</td><td class="benchmarkresult">18.3</td><td class="benchmarkresult">7.33</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/512</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">15.7</td><td class="benchmarkresult">18.2</td><td class="benchmarkresult">7.44</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/1024</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">16.1</td><td class="benchmarkresult">15.8</td><td class="benchmarkresult">18.2</td><td class="benchmarkresult">7.35</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/2048</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">16.2</td><td class="benchmarkresult">16.8</td><td class="benchmarkresult">18.3</td><td class="benchmarkresult">7.33</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">stringa copy{str_with_len_N};/4096</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">И как видно, кроме инкремента нет накладных расходов,
|
||
время копирования не зависит от длины строки.
|
||
And as you can see, there are no overhead costs other than the
|
||
increment; copying time does not depend on the string length.</span></span></td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">16.0</td><td class="benchmarkresult">15.7</td><td class="benchmarkresult">18.3</td><td class="benchmarkresult">7.36</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/15</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">lstringa<16> использует SSO до 23 символов.
|
||
А в WASM 32-битная архитектура, SSO до 19 символов.
|
||
lstringa<16> uses SSO up to 23 characters.
|
||
WASM has a 32-bit architecture, so SSO is up to 19 characters.</span></span></td><td class="benchmarkresult">1.47</td><td class="benchmarkresult">1.10</td><td class="benchmarkresult">1.50</td><td class="benchmarkresult">4.84</td><td class="benchmarkresult">7.29</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/16</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.22</td><td class="benchmarkresult">5.38</td><td class="benchmarkresult">5.09</td><td class="benchmarkresult">8.98</td><td class="benchmarkresult">19.3</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/23</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.16</td><td class="benchmarkresult">5.43</td><td class="benchmarkresult">5.36</td><td class="benchmarkresult">9.08</td><td class="benchmarkresult">85.0</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/24</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">И после начинает вести себя при копировании, как std::string.
|
||
And then it starts to behave like std::string when copied.</span></span></td><td class="benchmarkresult">22.6</td><td class="benchmarkresult">23.6</td><td class="benchmarkresult">76.8</td><td class="benchmarkresult">81.2</td><td class="benchmarkresult">85.7</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/32</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">23.0</td><td class="benchmarkresult">23.5</td><td class="benchmarkresult">81.4</td><td class="benchmarkresult">85.0</td><td class="benchmarkresult">93.3</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/64</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">25.5</td><td class="benchmarkresult">25.7</td><td class="benchmarkresult">80.8</td><td class="benchmarkresult">83.7</td><td class="benchmarkresult">92.8</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/128</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">25.7</td><td class="benchmarkresult">25.6</td><td class="benchmarkresult">82.8</td><td class="benchmarkresult">90.0</td><td class="benchmarkresult">95.0</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/256</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">27.1</td><td class="benchmarkresult">28.0</td><td class="benchmarkresult">87.4</td><td class="benchmarkresult">93.2</td><td class="benchmarkresult">126</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/512</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">29.8</td><td class="benchmarkresult">29.6</td><td class="benchmarkresult">86.9</td><td class="benchmarkresult">91.0</td><td class="benchmarkresult">119</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/1024</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">51.8</td><td class="benchmarkresult">56.5</td><td class="benchmarkresult">93.4</td><td class="benchmarkresult">98.2</td><td class="benchmarkresult">120</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/2048</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">65.7</td><td class="benchmarkresult">66.4</td><td class="benchmarkresult">133</td><td class="benchmarkresult">130</td><td class="benchmarkresult">169</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<16> copy{str_with_len_N};/4096</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">86.4</td><td class="benchmarkresult">87.0</td><td class="benchmarkresult">189</td><td class="benchmarkresult">183</td><td class="benchmarkresult">236</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/15</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1.49</td><td class="benchmarkresult">1.14</td><td class="benchmarkresult">1.49</td><td class="benchmarkresult">4.03</td><td class="benchmarkresult">7.25</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/16</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.15</td><td class="benchmarkresult">4.46</td><td class="benchmarkresult">5.15</td><td class="benchmarkresult">8.78</td><td class="benchmarkresult">19.5</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/23</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.25</td><td class="benchmarkresult">4.67</td><td class="benchmarkresult">5.14</td><td class="benchmarkresult">8.82</td><td class="benchmarkresult">19.9</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/24</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.09</td><td class="benchmarkresult">4.10</td><td class="benchmarkresult">5.12</td><td class="benchmarkresult">8.74</td><td class="benchmarkresult">19.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/32</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5.26</td><td class="benchmarkresult">4.20</td><td class="benchmarkresult">8.25</td><td class="benchmarkresult">11.9</td><td class="benchmarkresult">22.7</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/64</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">6.39</td><td class="benchmarkresult">5.66</td><td class="benchmarkresult">8.00</td><td class="benchmarkresult">12.3</td><td class="benchmarkresult">22.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/128</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">6.59</td><td class="benchmarkresult">6.97</td><td class="benchmarkresult">8.46</td><td class="benchmarkresult">12.4</td><td class="benchmarkresult">23.6</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/256</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.99</td><td class="benchmarkresult">7.99</td><td class="benchmarkresult">9.58</td><td class="benchmarkresult">13.4</td><td class="benchmarkresult">24.8</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/512</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Даже 512 символов копируются быстрее, чем
|
||
одна аллокация или атомарный инкремент.
|
||
Even 512 characters are copied faster than a single
|
||
allocation or atomic increment.</span></span></td><td class="benchmarkresult">10.5</td><td class="benchmarkresult">10.3</td><td class="benchmarkresult">11.0</td><td class="benchmarkresult">14.7</td><td class="benchmarkresult">28.3</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/1024</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А дальше уже как у всех.
|
||
And then it's like everyone else.</span></span></td><td class="benchmarkresult">52.1</td><td class="benchmarkresult">54.2</td><td class="benchmarkresult">94.5</td><td class="benchmarkresult">93.5</td><td class="benchmarkresult">121</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/2048</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">64.9</td><td class="benchmarkresult">66.7</td><td class="benchmarkresult">134</td><td class="benchmarkresult">127</td><td class="benchmarkresult">167</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L786">lstringa<512> copy{str_with_len_N};/4096</a><span class="tooltiptext code">template<typename T>
|
||
void CopyDynString(benchmark::State& state) {
|
||
T x(state.range(0), 'a');
|
||
for (auto _: state) {
|
||
T copy{x};
|
||
benchmark::DoNotOptimize(copy);
|
||
benchmark::DoNotOptimize(x);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">87.6</td><td class="benchmarkresult">85.2</td><td class="benchmarkresult">193</td><td class="benchmarkresult">192</td><td class="benchmarkresult">237</td></tr>
|
||
</tbody></table></div><script>bench_sets['Copy not literal Str with N symbols'] = {id:'bs15', tests:[
|
||
{name:'std::string copy{str_with_len_N};/15',data:[4.87,7.91,1.83,4.42,125]},
|
||
{name:'std::string copy{str_with_len_N};/16',data:[23.2,26.5,80.8,81.3,123]},
|
||
{name:'std::string copy{str_with_len_N};/23',data:[23.5,27.3,78.3,78.6,128]},
|
||
{name:'std::string copy{str_with_len_N};/24',data:[22.6,27.7,78.5,79.8,120]},
|
||
{name:'std::string copy{str_with_len_N};/32',data:[22.6,26.5,81.8,83.8,128]},
|
||
{name:'std::string copy{str_with_len_N};/64',data:[22.3,26.9,82.8,81.7,131]},
|
||
{name:'std::string copy{str_with_len_N};/128',data:[23.7,28.9,82.6,87.7,132]},
|
||
{name:'std::string copy{str_with_len_N};/256',data:[24.9,28.8,85.0,88.5,161]},
|
||
{name:'std::string copy{str_with_len_N};/512',data:[28.5,33.6,86.5,92.7,149]},
|
||
{name:'std::string copy{str_with_len_N};/1024',data:[34.8,44.2,95.3,97.1,156]},
|
||
{name:'std::string copy{str_with_len_N};/2048',data:[79.1,80.3,133,129,206]},
|
||
{name:'std::string copy{str_with_len_N};/4096',data:[111,115,179,180,271]},
|
||
{name:'stringa copy{str_with_len_N};/15',data:[1.09,1.09,1.29,4.00,4.60]},
|
||
{name:'stringa copy{str_with_len_N};/16',data:[1.13,1.10,1.32,4.02,7.36]},
|
||
{name:'stringa copy{str_with_len_N};/23',data:[1.11,1.10,1.29,4.10,7.39]},
|
||
{name:'stringa copy{str_with_len_N};/24',data:[15.9,16.1,15.8,18.4,7.35]},
|
||
{name:'stringa copy{str_with_len_N};/32',data:[16.0,16.0,15.8,18.4,7.33]},
|
||
{name:'stringa copy{str_with_len_N};/64',data:[16.0,16.1,15.8,18.3,7.37]},
|
||
{name:'stringa copy{str_with_len_N};/128',data:[16.0,16.0,15.7,18.4,7.30]},
|
||
{name:'stringa copy{str_with_len_N};/256',data:[16.0,15.9,15.8,18.3,7.33]},
|
||
{name:'stringa copy{str_with_len_N};/512',data:[16.0,16.0,15.7,18.2,7.44]},
|
||
{name:'stringa copy{str_with_len_N};/1024',data:[16.0,16.1,15.8,18.2,7.35]},
|
||
{name:'stringa copy{str_with_len_N};/2048',data:[15.9,16.2,16.8,18.3,7.33]},
|
||
{name:'stringa copy{str_with_len_N};/4096',data:[15.9,16.0,15.7,18.3,7.36]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/15',data:[1.47,1.10,1.50,4.84,7.29]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/16',data:[5.22,5.38,5.09,8.98,19.3]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/23',data:[5.16,5.43,5.36,9.08,85.0]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/24',data:[22.6,23.6,76.8,81.2,85.7]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/32',data:[23.0,23.5,81.4,85.0,93.3]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/64',data:[25.5,25.7,80.8,83.7,92.8]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/128',data:[25.7,25.6,82.8,90.0,95.0]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/256',data:[27.1,28.0,87.4,93.2,126]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/512',data:[29.8,29.6,86.9,91.0,119]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/1024',data:[51.8,56.5,93.4,98.2,120]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/2048',data:[65.7,66.4,133,130,169]},
|
||
{name:'lstringa<16> copy{str_with_len_N};/4096',data:[86.4,87.0,189,183,236]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/15',data:[1.49,1.14,1.49,4.03,7.25]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/16',data:[5.15,4.46,5.15,8.78,19.5]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/23',data:[5.25,4.67,5.14,8.82,19.9]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/24',data:[5.09,4.10,5.12,8.74,19.4]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/32',data:[5.26,4.20,8.25,11.9,22.7]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/64',data:[6.39,5.66,8.00,12.3,22.4]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/128',data:[6.59,6.97,8.46,12.4,23.6]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/256',data:[7.99,7.99,9.58,13.4,24.8]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/512',data:[10.5,10.3,11.0,14.7,28.3]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/1024',data:[52.1,54.2,94.5,93.5,121]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/2048',data:[64.9,66.7,134,127,167]},
|
||
{name:'lstringa<512> copy{str_with_len_N};/4096',data:[87.6,85.2,193,192,237]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs16"><h4><a id="bs94756718925776995960" href="#bs94756718925776995960">#</a> Convert to int '1234567'</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L801">std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);</a><span class="tooltiptext code">void ToIntStr10(benchmark::State& state, const std::string& s, int c) {
|
||
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", но он к сожалению очень ограничен
|
||
по возможностям. Здесь я попытался произвести тесты, близкие по
|
||
логике к работе std::from_chars
|
||
In simstr, a string fragment is sufficient for conversion to a number;
|
||
there's no need for null termination. The closest analog to this behavior
|
||
is "std::from_chars," but unfortunately, it is very limited in its capabilities.
|
||
Here, I attempted to run tests that are similar in logic to std::from_chars.</span></span></td><td class="benchmarkresult">26.9</td><td class="benchmarkresult">27.2</td><td class="benchmarkresult">30.6</td><td class="benchmarkresult">31.5</td><td class="benchmarkresult">203</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L840">std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);</a><span class="tooltiptext code">void ToIntFromChars10(benchmark::State& state, const std::string_view& s, int c) {
|
||
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 требует точного указания основания счисления,
|
||
не допускает знаков плюс, пробелов, префиксов 0x и т.п.
|
||
from_chars requires an exact radix specification and does not allow plus
|
||
signs, spaces, 0x prefixes, etc.</span></span></td><td class="benchmarkresult">14.5</td><td class="benchmarkresult">12.0</td><td class="benchmarkresult">13.5</td><td class="benchmarkresult">14.8</td><td class="benchmarkresult">2.18</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L868">stringa s = "123456789"; int res = s.to_int<int, true, 10, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr10(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 10, false, false>().value;
|
||
#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 заданы такие же ограничения - проверять переполнение,
|
||
десятичная система, без лидирующих пробелов и знака плюс
|
||
Here, to_int has the same restrictions: check for overflow,
|
||
decimal system, no leading spaces, and no plus sign.</span></span></td><td class="benchmarkresult">9.62</td><td class="benchmarkresult">8.54</td><td class="benchmarkresult">13.8</td><td class="benchmarkresult">15.9</td><td class="benchmarkresult">50.4</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L868">ssa s = "123456789"; int res = s.to_int<int, true, 10, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr10(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 10, false, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">9.84</td><td class="benchmarkresult">7.79</td><td class="benchmarkresult">9.17</td><td class="benchmarkresult">15.2</td><td class="benchmarkresult">47.5</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L868">lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr10(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 10, false, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">9.22</td><td class="benchmarkresult">8.67</td><td class="benchmarkresult">13.9</td><td class="benchmarkresult">15.3</td><td class="benchmarkresult">46.7</td></tr>
|
||
</tbody></table></div><script>bench_sets['Convert to int \'1234567\''] = {id:'bs16', tests:[
|
||
{name:'std::string s = "123456789"; int res = std::strtol(s.c_str(), 0, 10);',data:[26.9,27.2,30.6,31.5,203]},
|
||
{name:'std::string_view s = "123456789"; std::from_chars(s.data(), s.data() + s.size(), res, 10);',data:[14.5,12.0,13.5,14.8,2.18]},
|
||
{name:'stringa s = "123456789"; int res = s.to_int<int, true, 10, false>',data:[9.62,8.54,13.8,15.9,50.4]},
|
||
{name:'ssa s = "123456789"; int res = s.to_int<int, true, 10, false>',data:[9.84,7.79,9.17,15.2,47.5]},
|
||
{name:'lstringa<20> s = "123456789"; int res = s.to_int<int, true, 10, false>',data:[9.22,8.67,13.9,15.3,46.7]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs17"><h4><a id="bs182426078870126042750" href="#bs182426078870126042750">#</a> Convert to unsigned 'abcDef'</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L814">std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);</a><span class="tooltiptext code">void ToIntStr16(benchmark::State& state, const std::string& s, int c) {
|
||
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);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Всё то же, только для 16ричной системы
|
||
Everything is the same, only for the hexadecimal system</span></span></td><td class="benchmarkresult">22.8</td><td class="benchmarkresult">23.8</td><td class="benchmarkresult">34.2</td><td class="benchmarkresult">34.5</td><td class="benchmarkresult">151</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L854">std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);</a><span class="tooltiptext code">void ToIntFromChars16(benchmark::State& state, const std::string_view& s, int c) {
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">9.22</td><td class="benchmarkresult">8.07</td><td class="benchmarkresult">8.11</td><td class="benchmarkresult">9.16</td><td class="benchmarkresult">53.9</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L883">stringa s = "abcDef"; int res = s.to_int<int, true, 16, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr16(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 16, false, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.55</td><td class="benchmarkresult">8.44</td><td class="benchmarkresult">12.7</td><td class="benchmarkresult">13.8</td><td class="benchmarkresult">46.1</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L883">ssa s = "abcDef"; int res = s.to_int<int, true, 16, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr16(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 16, false, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.55</td><td class="benchmarkresult">6.72</td><td class="benchmarkresult">7.39</td><td class="benchmarkresult">13.4</td><td class="benchmarkresult">44.8</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L883">lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false></a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr16(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int, true, 16, false, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">7.45</td><td class="benchmarkresult">8.42</td><td class="benchmarkresult">12.7</td><td class="benchmarkresult">13.6</td><td class="benchmarkresult">44.0</td></tr>
|
||
</tbody></table></div><script>bench_sets['Convert to unsigned \'abcDef\''] = {id:'bs17', tests:[
|
||
{name:'std::string s = "abcDef"; int res = std::strtol(s.c_str(), 0, 16);',data:[22.8,23.8,34.2,34.5,151]},
|
||
{name:'std::string_view s = "abcDef"; std::from_chars(s.data(), s.data() + s.size(), res, 16);',data:[9.22,8.07,8.11,9.16,53.9]},
|
||
{name:'stringa s = "abcDef"; int res = s.to_int<int, true, 16, false>',data:[7.55,8.44,12.7,13.8,46.1]},
|
||
{name:'ssa s = "abcDef"; int res = s.to_int<int, true, 16, false>',data:[7.55,6.72,7.39,13.4,44.8]},
|
||
{name:'lstringa<20> s = "abcDef"; int res = s.to_int<int, true, 16, false>',data:[7.45,8.42,12.7,13.6,44.0]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs18"><h4><a id="bs52606100125109966680" href="#bs52606100125109966680">#</a> Convert to int ' 1234567'</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L827">std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);</a><span class="tooltiptext code">void ToIntStr0(benchmark::State& state, const std::string& s, int c) {
|
||
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);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А здесь уже парсинг произвольного числа.
|
||
And here we have parsing of an arbitrary number.</span></span></td><td class="benchmarkresult">28.8</td><td class="benchmarkresult">27.8</td><td class="benchmarkresult">42.8</td><td class="benchmarkresult">44.1</td><td class="benchmarkresult">219</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L898">stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow</a><span class="tooltiptext code">template<typename T>
|
||
void ToIntSimStr0(benchmark::State& state, T t, int c) {
|
||
for (auto _: state) {
|
||
int res = t. template to_int<int>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">11.4</td><td class="benchmarkresult">15.3</td><td class="benchmarkresult">18.5</td><td class="benchmarkresult">22.3</td><td class="benchmarkresult">35.2</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L913">ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow</a><span class="tooltiptext code">void ToIntNoOverflow(benchmark::State& state, ssa t, int c) {
|
||
for (auto _: state) {
|
||
int res = t.to_int<int, false>().value;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">12.9</td><td class="benchmarkresult">10.8</td><td class="benchmarkresult">13.6</td><td class="benchmarkresult">18.8</td><td class="benchmarkresult">44.3</td></tr>
|
||
</tbody></table></div><script>bench_sets['Convert to int \' 1234567\''] = {id:'bs18', tests:[
|
||
{name:'std::string s = " 123456789"; int res = std::strtol(s.c_str(), 0, 0);',data:[28.8,27.8,42.8,44.1,219]},
|
||
{name:'stringa s = " 123456789"; int res = s.to_int<int>; // Check overflow',data:[11.4,15.3,18.5,22.3,35.2]},
|
||
{name:'ssa s = " 123456789"; int res = s.to_int<int, false>; // No check overflow',data:[12.9,10.8,13.6,18.8,44.3]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs19"><h4><a id="bs182348477702821075660" href="#bs182348477702821075660">#</a> Convert to double '1234.567e10'</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L943">std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);</a><span class="tooltiptext code">void ToDoubleStr(benchmark::State& state, const std::string& s, double c) {
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">66.2</td><td class="benchmarkresult">62.8</td><td class="benchmarkresult">97.9</td><td class="benchmarkresult">103</td><td class="benchmarkresult">633</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L960">std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);</a><span class="tooltiptext code">void ToDoubleFromChars(benchmark::State& state, const std::string_view& s, double c) {
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">23.6</td><td class="benchmarkresult">24.2</td><td class="benchmarkresult">58.4</td><td class="benchmarkresult">77.6</td><td class="benchmarkresult">279</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L976">ssa s = "1234.567e10"; double res = *s.to_double()</a><span class="tooltiptext code">template<typename T>
|
||
void ToDoubleSimStr(benchmark::State& state, T t, double c) {
|
||
for (auto _: state) {
|
||
auto r = t.template to_double<false>();
|
||
if (!r) {
|
||
state.SkipWithError("not equal");
|
||
}
|
||
double res = *r;
|
||
#ifdef CHECK_RESULT
|
||
if (res != c) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
benchmark::DoNotOptimize(t);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">24.8</td><td class="benchmarkresult">24.5</td><td class="benchmarkresult">35.1</td><td class="benchmarkresult">36.4</td><td class="benchmarkresult">91.4</td></tr>
|
||
</tbody></table></div><script>bench_sets['Convert to double \'1234.567e10\''] = {id:'bs19', tests:[
|
||
{name:'std::string s = "1234.567e10"; double res = std::strtod(s.c_str(), nullptr);',data:[66.2,62.8,97.9,103,633]},
|
||
{name:'std::string_view s = "1234.567e10"; std::from_chars(s.data(), s.data() + s.size(), res);',data:[23.6,24.2,58.4,77.6,279]},
|
||
{name:'ssa s = "1234.567e10"; double res = *s.to_double()',data:[24.8,24.5,35.1,36.4,91.4]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs20"><h4><a id="bs96505608161678391610" href="#bs96505608161678391610">#</a> Append const literal of 16 bytes 64 times, 1024 total length</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1000">std::stringstream str; ... str << "abbaabbaabbaabba";</a><span class="tooltiptext code">void AppendStreamConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
std::string result;
|
||
std::stringstream str;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
str << TEXT_16;
|
||
}
|
||
result = str.str();
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(str);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1336</td><td class="benchmarkresult">1345</td><td class="benchmarkresult">4844</td><td class="benchmarkresult">5669</td><td class="benchmarkresult">15882</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1019">std::string str; ... str += "abbaabbaabbaabba";</a><span class="tooltiptext code">void AppendStdStringConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
std::string result;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
result += TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">407</td><td class="benchmarkresult">346</td><td class="benchmarkresult">1045</td><td class="benchmarkresult">1305</td><td class="benchmarkresult">1402</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1035">lstringa<8> str; ... str += "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
result += TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">376</td><td class="benchmarkresult">345</td><td class="benchmarkresult">782</td><td class="benchmarkresult">986</td><td class="benchmarkresult">1320</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1035">lstringa<128> str; ... str += "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
result += TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Чем больше внутренний буфер, тем меньше раз требуется
|
||
аллокация, тем быстрее результат.
|
||
The larger the internal buffer, the fewer allocations are
|
||
required, and the faster the result.</span></span></td><td class="benchmarkresult">236</td><td class="benchmarkresult">239</td><td class="benchmarkresult">406</td><td class="benchmarkresult">582</td><td class="benchmarkresult">889</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1035">lstringa<512> str; ... str += "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
result += TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">206</td><td class="benchmarkresult">209</td><td class="benchmarkresult">268</td><td class="benchmarkresult">400</td><td class="benchmarkresult">624</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1035">lstringa<1024> str; ... str += "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringConstLiteral(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 64; c++) {
|
||
result += TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">136</td><td class="benchmarkresult">139</td><td class="benchmarkresult">156</td><td class="benchmarkresult">244</td><td class="benchmarkresult">497</td></tr>
|
||
</tbody></table></div><script>bench_sets['Append const literal of 16 bytes 64 times, 1024 total length'] = {id:'bs20', tests:[
|
||
{name:'std::stringstream str; ... str << "abbaabbaabbaabba";',data:[1336,1345,4844,5669,15882]},
|
||
{name:'std::string str; ... str += "abbaabbaabbaabba";',data:[407,346,1045,1305,1402]},
|
||
{name:'lstringa<8> str; ... str += "abbaabbaabbaabba";',data:[376,345,782,986,1320]},
|
||
{name:'lstringa<128> str; ... str += "abbaabbaabbaabba";',data:[236,239,406,582,889]},
|
||
{name:'lstringa<512> str; ... str += "abbaabbaabbaabba";',data:[206,209,268,400,624]},
|
||
{name:'lstringa<1024> str; ... str += "abbaabbaabbaabba";',data:[136,139,156,244,497]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs21"><h4><a id="bs36931044816721597850" href="#bs36931044816721597850">#</a> Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1060">std::stringstream str; ... str << str_var << "abbaabbaabbaabba";</a><span class="tooltiptext code">void AppendStreamStrConstLiteral(benchmark::State& state) {
|
||
std::string s1 = TEXT_16;
|
||
for (auto _: state) {
|
||
std::string result;
|
||
std::stringstream s;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
s << s1 << TEXT_16;
|
||
}
|
||
result = s.str();
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1362</td><td class="benchmarkresult">1345</td><td class="benchmarkresult">4654</td><td class="benchmarkresult">5946</td><td class="benchmarkresult">16035</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1080">std::string str; ... str += str_var + "abbaabbaabbaabba";</a><span class="tooltiptext code">void AppendStdStrStrConstLiteral(benchmark::State& state) {
|
||
std::string p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
std::string result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1221</td><td class="benchmarkresult">1298</td><td class="benchmarkresult">3736</td><td class="benchmarkresult">4420</td><td class="benchmarkresult">4646</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1098">lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteral(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">385</td><td class="benchmarkresult">403</td><td class="benchmarkresult">713</td><td class="benchmarkresult">920</td><td class="benchmarkresult">1514</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1098">lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteral(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">301</td><td class="benchmarkresult">342</td><td class="benchmarkresult">437</td><td class="benchmarkresult">635</td><td class="benchmarkresult">1209</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1098">lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteral(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">293</td><td class="benchmarkresult">299</td><td class="benchmarkresult">281</td><td class="benchmarkresult">384</td><td class="benchmarkresult">986</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1098">lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteral(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">235</td><td class="benchmarkresult">254</td><td class="benchmarkresult">187</td><td class="benchmarkresult">273</td><td class="benchmarkresult">827</td></tr>
|
||
</tbody></table></div><script>bench_sets['Append string of 16 bytes and const literal of 16 bytes 32 times, 1024 total length'] = {id:'bs21', tests:[
|
||
{name:'std::stringstream str; ... str << str_var << "abbaabbaabbaabba";',data:[1362,1345,4654,5946,16035]},
|
||
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba";',data:[1221,1298,3736,4420,4646]},
|
||
{name:'lstringa<8> str; ... str += str_var + "abbaabbaabbaabba";',data:[385,403,713,920,1514]},
|
||
{name:'lstringa<128> str; ... str += str_var + "abbaabbaabbaabba";',data:[301,342,437,635,1209]},
|
||
{name:'lstringa<512> str; ... str += str_var + "abbaabbaabbaabba";',data:[293,299,281,384,986]},
|
||
{name:'lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba";',data:[235,254,187,273,827]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs22"><h4><a id="bs8293767858383349360" href="#bs8293767858383349360">#</a> Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1126">std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">void AppendStreamStrConstLiteralBig(benchmark::State& state) {
|
||
std::string s1 = TEXT_16;
|
||
for (auto _: state) {
|
||
std::string result;
|
||
std::stringstream s;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
s << s1 << TEXT_16;
|
||
}
|
||
result = s.str();
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">111021</td><td class="benchmarkresult">113874</td><td class="benchmarkresult">234977</td><td class="benchmarkresult">272220</td><td class="benchmarkresult">821457</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1146">std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">void AppendStdStrStrConstLiteralBig(benchmark::State& state) {
|
||
std::string p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
std::string result;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">69967</td><td class="benchmarkresult">73347</td><td class="benchmarkresult">192544</td><td class="benchmarkresult">203527</td><td class="benchmarkresult">238655</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1164">lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">45414</td><td class="benchmarkresult">44770</td><td class="benchmarkresult">20077</td><td class="benchmarkresult">24303</td><td class="benchmarkresult">58092</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1164">lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">23033</td><td class="benchmarkresult">25460</td><td class="benchmarkresult">16403</td><td class="benchmarkresult">22770</td><td class="benchmarkresult">56704</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1164">lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">19267</td><td class="benchmarkresult">18428</td><td class="benchmarkresult">16237</td><td class="benchmarkresult">22095</td><td class="benchmarkresult">55779</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1164">lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstringStrConstLiteralBig(benchmark::State& state) {
|
||
stringa p1 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 2048; c++) {
|
||
result += p1 + TEXT_16;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024 * 64) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(p1);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">17475</td><td class="benchmarkresult">17351</td><td class="benchmarkresult">15954</td><td class="benchmarkresult">21427</td><td class="benchmarkresult">56710</td></tr>
|
||
</tbody></table></div><script>bench_sets['Append string of 16 bytes and const literal of 16 bytes 2048 times, 65536 total length'] = {id:'bs22', tests:[
|
||
{name:'std::stringstream str; ... str << str_var << "abbaabbaabbaabba"; 2048 times',data:[111021,113874,234977,272220,821457]},
|
||
{name:'std::string str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[69967,73347,192544,203527,238655]},
|
||
{name:'lstringa<8> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[45414,44770,20077,24303,58092]},
|
||
{name:'lstringa<128> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[23033,25460,16403,22770,56704]},
|
||
{name:'lstringa<512> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[19267,18428,16237,22095,55779]},
|
||
{name:'lstringa<1024> str; ... str += str_var + "abbaabbaabbaabba"; 2048 times',data:[17475,17351,15954,21427,56710]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs23"><h4><a id="bs66949588770596833730" href="#bs66949588770596833730">#</a> Append 2 string of 16 bytes 32 times, 1024 total length</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1191">std::stringstream str; ... str << str_var1 << str_var2;</a><span class="tooltiptext code">void AppendStream2String(benchmark::State& state) {
|
||
std::string s1 = TEXT_16;
|
||
std::string s2 = TEXT_16;
|
||
for (auto _: state) {
|
||
std::string result;
|
||
std::stringstream s;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
s << s1 << s2;
|
||
}
|
||
result = s.str();
|
||
#ifdef CHECK_RESULT
|
||
if (result.size() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
benchmark::DoNotOptimize(s2);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1361</td><td class="benchmarkresult">1352</td><td class="benchmarkresult">4325</td><td class="benchmarkresult">5265</td><td class="benchmarkresult">16125</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1213">std::string str; ... str += str_var1 + str_var2;</a><span class="tooltiptext code">void AppendStdStr2String(benchmark::State& state) {
|
||
std::string s1 = TEXT_16;
|
||
std::string s2 = TEXT_16;
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1397</td><td class="benchmarkresult">1422</td><td class="benchmarkresult">4072</td><td class="benchmarkresult">4034</td><td class="benchmarkresult">5089</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1234">lstringa<16> str; ... str += str_var1 + str_var2;</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstring2String(benchmark::State& state) {
|
||
stra s1 = TEXT_16;
|
||
stra s2 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += s1 + s2;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
benchmark::DoNotOptimize(s2);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">452</td><td class="benchmarkresult">465</td><td class="benchmarkresult">794</td><td class="benchmarkresult">911</td><td class="benchmarkresult">1846</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1234">lstringa<128> str; ... str += str_var1 + str_var2;</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstring2String(benchmark::State& state) {
|
||
stra s1 = TEXT_16;
|
||
stra s2 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += s1 + s2;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
benchmark::DoNotOptimize(s2);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">407</td><td class="benchmarkresult">415</td><td class="benchmarkresult">512</td><td class="benchmarkresult">620</td><td class="benchmarkresult">1663</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1234">lstringa<512> str; ... str += str_var1 + str_var2;</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstring2String(benchmark::State& state) {
|
||
stra s1 = TEXT_16;
|
||
stra s2 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += s1 + s2;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
benchmark::DoNotOptimize(s2);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">351</td><td class="benchmarkresult">361</td><td class="benchmarkresult">395</td><td class="benchmarkresult">469</td><td class="benchmarkresult">1291</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1234">lstringa<1024> str; ... str += str_var1 + str_var2;</a><span class="tooltiptext code">template<unsigned N>
|
||
void AppendLstring2String(benchmark::State& state) {
|
||
stra s1 = TEXT_16;
|
||
stra s2 = TEXT_16;
|
||
for (auto _: state) {
|
||
lstringa<N> result;
|
||
for (size_t c = 0; c < 32; c++) {
|
||
result += s1 + s2;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result.length() != 1024) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(s1);
|
||
benchmark::DoNotOptimize(s2);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">300</td><td class="benchmarkresult">322</td><td class="benchmarkresult">287</td><td class="benchmarkresult">362</td><td class="benchmarkresult">1066</td></tr>
|
||
</tbody></table></div><script>bench_sets['Append 2 string of 16 bytes 32 times, 1024 total length'] = {id:'bs23', tests:[
|
||
{name:'std::stringstream str; ... str << str_var1 << str_var2;',data:[1361,1352,4325,5265,16125]},
|
||
{name:'std::string str; ... str += str_var1 + str_var2;',data:[1397,1422,4072,4034,5089]},
|
||
{name:'lstringa<16> str; ... str += str_var1 + str_var2;',data:[452,465,794,911,1846]},
|
||
{name:'lstringa<128> str; ... str += str_var1 + str_var2;',data:[407,415,512,620,1663]},
|
||
{name:'lstringa<512> str; ... str += str_var1 + str_var2;',data:[351,361,395,469,1291]},
|
||
{name:'lstringa<1024> str; ... str += str_var1 + str_var2;',data:[300,322,287,362,1066]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs24"><h4><a id="bs130432147582115154460" href="#bs130432147582115154460">#</a> Append text, number, text</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1263">std::stringstream str; str << "test = " << k << " times";</a><span class="tooltiptext code">void AppendStreamStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
std::stringstream t;
|
||
t << "test = " << k << " times";
|
||
std::string result = t.str();
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">3011</td><td class="benchmarkresult">3192</td><td class="benchmarkresult">10825</td><td class="benchmarkresult">11467</td><td class="benchmarkresult">25591</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1281">std::string str = "test = " + std::to_string(k) + " times";</a><span class="tooltiptext code">void AppendStdStringStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
std::string result = "test = " + std::to_string(k) + " times";
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">434</td><td class="benchmarkresult">505</td><td class="benchmarkresult">1066</td><td class="benchmarkresult">1162</td><td class="benchmarkresult">3456</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1297">char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;</a><span class="tooltiptext code">void AppendSprintfStrNumStr(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1391</td><td class="benchmarkresult">1544</td><td class="benchmarkresult">2723</td><td class="benchmarkresult">2743</td><td class="benchmarkresult">10939</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1315">std::string str = std::format("test = {} times", k);</a><span class="tooltiptext code">void AppendFormatStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
std::string result = std::format("test = {} times", k);
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1154</td><td class="benchmarkresult">1453</td><td class="benchmarkresult">1842</td><td class="benchmarkresult">2397</td><td class="benchmarkresult">5707</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1331">lstringa<8> str; str.format("test = {} times", k);</a><span class="tooltiptext code">template<typename T>
|
||
void AppendSimStrStrNumStrF(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
T result;
|
||
result.format("test = {} times", k);
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</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
|
||
string without allocation.</span></span></td><td class="benchmarkresult">1374</td><td class="benchmarkresult">1547</td><td class="benchmarkresult">2012</td><td class="benchmarkresult">2712</td><td class="benchmarkresult">8601</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1331">lstringa<32> str; str.format("test = {} times", k);</a><span class="tooltiptext code">template<typename T>
|
||
void AppendSimStrStrNumStrF(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
T result;
|
||
result.format("test = {} times", k);
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А в такую помещается. Используйте сразу буфера подходящего размера.
|
||
And it fits in this one. Use buffers of the appropriate size right away.</span></span></td><td class="benchmarkresult">997</td><td class="benchmarkresult">1083</td><td class="benchmarkresult">1004</td><td class="benchmarkresult">1521</td><td class="benchmarkresult">7339</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1349">lstringa<8> str = "test = " + k + " times";</a><span class="tooltiptext code">template<typename T>
|
||
void AppendSimStrStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
T result = "test = "_ss + k + " times";
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Результат не помещается в SSO, возникает аллокация.
|
||
The result does not fit into SSO, an allocation occurs.</span></span></td><td class="benchmarkresult">272</td><td class="benchmarkresult">295</td><td class="benchmarkresult">821</td><td class="benchmarkresult">899</td><td class="benchmarkresult">1332</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1349">lstringa<32> str = "test = " + k + " times";</a><span class="tooltiptext code">template<typename T>
|
||
void AppendSimStrStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
T result = "test = "_ss + k + " times";
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">А здесь и ниже - результат укладывается в SSO.
|
||
Ещё раз - используйте сразу буфера подходящего размера.
|
||
And here and below, the result fits within SSO.
|
||
Once again, use appropriately sized buffers from the start.</span></span></td><td class="benchmarkresult">124</td><td class="benchmarkresult">149</td><td class="benchmarkresult">136</td><td class="benchmarkresult">177</td><td class="benchmarkresult">570</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1349">stringa str = "test = " + k + " times";</a><span class="tooltiptext code">template<typename T>
|
||
void AppendSimStrStrNumStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
for (unsigned k = 1; k <= 1'000'000'000; k *= 10) {
|
||
T result = "test = "_ss + k + " times";
|
||
#ifdef CHECK_RESULT
|
||
if (!result.starts_with("test = ") || !result.ends_with(" times")) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(k);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Под WASM размер SSO 15 символов, что явно не хватает для размещения
|
||
результата, отсюда и такое время.
|
||
Under WASM, the SSO size is 15 characters, which is clearly not
|
||
enough to accommodate the result, hence the long time.</span></span></td><td class="benchmarkresult">117</td><td class="benchmarkresult">130</td><td class="benchmarkresult">121</td><td class="benchmarkresult">178</td><td class="benchmarkresult">1253</td></tr>
|
||
</tbody></table></div><script>bench_sets['Append text, number, text'] = {id:'bs24', tests:[
|
||
{name:'std::stringstream str; str << "test = " << k << " times";',data:[3011,3192,10825,11467,25591]},
|
||
{name:'std::string str = "test = " + std::to_string(k) + " times";',data:[434,505,1066,1162,3456]},
|
||
{name:'char buf[100]; sprintf(buf, "test = %u times", k); std::string str = buf;',data:[1391,1544,2723,2743,10939]},
|
||
{name:'std::string str = std::format("test = {} times", k);',data:[1154,1453,1842,2397,5707]},
|
||
{name:'lstringa<8> str; str.format("test = {} times", k);',data:[1374,1547,2012,2712,8601]},
|
||
{name:'lstringa<32> str; str.format("test = {} times", k);',data:[997,1083,1004,1521,7339]},
|
||
{name:'lstringa<8> str = "test = " + k + " times";',data:[272,295,821,899,1332]},
|
||
{name:'lstringa<32> str = "test = " + k + " times";',data:[124,149,136,177,570]},
|
||
{name:'stringa str = "test = " + k + " times";',data:[117,130,121,178,1253]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs25"><h4><a id="bs7106975351756760120" href="#bs7106975351756760120">#</a> Split text and convert to int</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1379">std::string::find + substr + std::strtol</a><span class="tooltiptext code">void SplitConvertIntStdString(benchmark::State& state) {
|
||
std::string numbers = NUMBER_LIST;
|
||
for (auto _: state) {
|
||
int total = 0;
|
||
for (size_t start = 0; start < numbers.length(); ) {
|
||
int delim = numbers.find("-!-", start);
|
||
if (delim == std::string::npos) {
|
||
delim = numbers.size();
|
||
}
|
||
std::string part = numbers.substr(start, delim - start);
|
||
total += std::strtol(part.c_str(), nullptr, 0);
|
||
start = delim + 3;
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (total != 218) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(total);
|
||
benchmark::DoNotOptimize(numbers);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">266</td><td class="benchmarkresult">275</td><td class="benchmarkresult">546</td><td class="benchmarkresult">551</td><td class="benchmarkresult">1483</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1403">ssa::splitter + ssa::as_int</a><span class="tooltiptext code">void SplitConvertIntSimStr(benchmark::State& state) {
|
||
stra numbers = NUMBER_LIST;
|
||
for (auto _: state) {
|
||
int total = 0;
|
||
for (auto splitter = numbers.splitter("-!-"); !splitter.is_done();) {
|
||
total += splitter.next().as_int<int>();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (total != 218) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(total);
|
||
benchmark::DoNotOptimize(numbers);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">156</td><td class="benchmarkresult">151</td><td class="benchmarkresult">165</td><td class="benchmarkresult">300</td><td class="benchmarkresult">587</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1420">ssa::splitf + functor</a><span class="tooltiptext code">void SplitConvertIntSplitf(benchmark::State& state) {
|
||
stra numbers = NUMBER_LIST;
|
||
for (auto _: state) {
|
||
int total = 0;
|
||
numbers.splitf<void>("-!-", [&](ssa& part){total += part.as_int<int>();});
|
||
#ifdef CHECK_RESULT
|
||
if (total != 218) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(total);
|
||
benchmark::DoNotOptimize(numbers);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">208</td><td class="benchmarkresult">122</td><td class="benchmarkresult">191</td><td class="benchmarkresult">215</td><td class="benchmarkresult">840</td></tr>
|
||
</tbody></table></div><script>bench_sets['Split text and convert to int'] = {id:'bs25', tests:[
|
||
{name:'std::string::find + substr + std::strtol',data:[266,275,546,551,1483]},
|
||
{name:'ssa::splitter + ssa::as_int',data:[156,151,165,300,587]},
|
||
{name:'ssa::splitf + functor',data:[208,122,191,215,840]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs26"><h4><a id="bs151373809886162287550" href="#bs151373809886162287550">#</a> Replace symbols in text ~400 symbols</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1441">Naive (and wrong) replace symbols with std::string find + replace</a><span class="tooltiptext code">void ReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
|
||
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'. Но если замены не конфликтуют,
|
||
то работает быстро.
|
||
This is a naive implementation that will fail to handle substitutions
|
||
such as 'a'->'b' and 'b'->'a'. But if the substitutions don't conflict,
|
||
it works quickly.</span></span></td><td class="benchmarkresult">835</td><td class="benchmarkresult">834</td><td class="benchmarkresult">1108</td><td class="benchmarkresult">1224</td><td class="benchmarkresult">4781</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1495">replace symbols with std::string find_first_of + replace</a><span class="tooltiptext code">void ReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
|
||
std::string_view source =
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
;
|
||
std::vector<std::pair<u8s, std::string_view>> repl = {
|
||
{'-', ""},
|
||
{'<', "&lt;"},
|
||
{'>', "&gt;"},
|
||
{'\'', "&#39;"},
|
||
{'\"', "&quot;"},
|
||
{'&', "&amp;"},
|
||
};
|
||
|
||
for (auto _: state) {
|
||
std::string result{source};
|
||
std::string pattern;
|
||
for (const auto& r : repl) {
|
||
pattern += r.first;
|
||
}
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find_first_of(pattern, start_pos)) != std::string::npos) {
|
||
size_t idx = pattern.find(result[start_pos]);
|
||
result.replace(start_pos, 1, repl[idx].second);
|
||
start_pos += repl[idx].second.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result
|
||
!=
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Дальше уже правильные реализации, не зависящие от конфликтующих замен.
|
||
Further, there are correct implementations that do not depend on
|
||
conflicting replacements.</span></span></td><td class="benchmarkresult">2459</td><td class="benchmarkresult">2603</td><td class="benchmarkresult">2009</td><td class="benchmarkresult">2264</td><td class="benchmarkresult">8914</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1549">replace symbols with std::string_view find_first_of + copy</a><span class="tooltiptext code">void ReplaceSymbolsStdString(benchmark::State& state) {
|
||
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"
|
||
;
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1128</td><td class="benchmarkresult">1037</td><td class="benchmarkresult">2277</td><td class="benchmarkresult">2662</td><td class="benchmarkresult">4601</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1602">replace runtime symbols with string expressions and without remembering all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1268</td><td class="benchmarkresult">1542</td><td class="benchmarkresult">1448</td><td class="benchmarkresult">1582</td><td class="benchmarkresult">4270</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1602">replace runtime symbols with simstr and memorization of all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
void ReplaceSymbolsDynPatternSimStr(benchmark::State& state) {
|
||
stra source =
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
" ksjd-fksjd \"dkjfs-jkhdf dfj ' kdkd \"dkfdkfkdjf"
|
||
;
|
||
|
||
std::vector<std::pair<u8s, ssa>> repl = {
|
||
{'-', ""},
|
||
{'<', "&lt;"},
|
||
{'>', "&gt;"},
|
||
{'\'', "&#39;"},
|
||
{'\"', "&quot;"},
|
||
{'&', "&amp;"},
|
||
};
|
||
|
||
for (auto _: state) {
|
||
stringa result = expr_replace_symbols<u8s, UseVector>{source, repl};
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result
|
||
!=
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
"abcdefg124 &lt; jhsfjsh sjdfsh jfhjd &amp;&amp; jdjdj &gt;"
|
||
" ksjdfksjd &quot;dkjfsjkhdf dfj &#39; kdkd &quot;dkfdkfkdjf"
|
||
) {
|
||
state.SkipWithError("not equal");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1010</td><td class="benchmarkresult">1156</td><td class="benchmarkresult">1363</td><td class="benchmarkresult">1398</td><td class="benchmarkresult">3830</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1649">replace const symbols with string expressions and without remembering all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1061</td><td class="benchmarkresult">1193</td><td class="benchmarkresult">1229</td><td class="benchmarkresult">1251</td><td class="benchmarkresult">3372</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1649">replace const symbols with string expressions and memorization of all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">840</td><td class="benchmarkresult">837</td><td class="benchmarkresult">1096</td><td class="benchmarkresult">1243</td><td class="benchmarkresult">2905</td></tr>
|
||
</tbody></table></div><script>bench_sets['Replace symbols in text ~400 symbols'] = {id:'bs26', tests:[
|
||
{name:'Naive (and wrong) replace symbols with std::string find + replace',data:[835,834,1108,1224,4781]},
|
||
{name:'replace symbols with std::string find_first_of + replace',data:[2459,2603,2009,2264,8914]},
|
||
{name:'replace symbols with std::string_view find_first_of + copy',data:[1128,1037,2277,2662,4601]},
|
||
{name:'replace runtime symbols with string expressions and without remembering all search results',data:[1268,1542,1448,1582,4270]},
|
||
{name:'replace runtime symbols with simstr and memorization of all search results',data:[1010,1156,1363,1398,3830]},
|
||
{name:'replace const symbols with string expressions and without remembering all search results',data:[1061,1193,1229,1251,3372]},
|
||
{name:'replace const symbols with string expressions and memorization of all search results',data:[840,837,1096,1243,2905]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs27"><h4><a id="bs96756339547767401190" href="#bs96756339547767401190">#</a> Replace symbols in text ~40 symbols</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1703">Short Naive (and wrong) replace symbols with std::string find + replace</a><span class="tooltiptext code">void ShortReplaceSymbolsStdStringNaiveWrong(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">150</td><td class="benchmarkresult">154</td><td class="benchmarkresult">305</td><td class="benchmarkresult">337</td><td class="benchmarkresult">866</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1743">Short replace symbols with std::string find_first_of + replace</a><span class="tooltiptext code">void ShortReplaceSymbolsStdStringNaiveRight(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">313</td><td class="benchmarkresult">301</td><td class="benchmarkresult">356</td><td class="benchmarkresult">423</td><td class="benchmarkresult">1328</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1783">Short replace symbols with std::string_view find_first_of + copy</a><span class="tooltiptext code">void ShortReplaceSymbolsStdString(benchmark::State& state) {
|
||
std::string_view source =
|
||
"abcdefg124 < jhsfjsh sjdfsh jfhjd && jdjdj >"
|
||
;
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">153</td><td class="benchmarkresult">154</td><td class="benchmarkresult">307</td><td class="benchmarkresult">350</td><td class="benchmarkresult">797</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1822">Short replace runtime symbols with string expressions and without remembering all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">172</td><td class="benchmarkresult">178</td><td class="benchmarkresult">259</td><td class="benchmarkresult">298</td><td class="benchmarkresult">656</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1822">Short replace runtime symbols with simstr and memorization of all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">173</td><td class="benchmarkresult">192</td><td class="benchmarkresult">355</td><td class="benchmarkresult">396</td><td class="benchmarkresult">831</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1855">Short replace const symbols with string expressions and without remembering all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">138</td><td class="benchmarkresult">149</td><td class="benchmarkresult">199</td><td class="benchmarkresult">253</td><td class="benchmarkresult">438</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1855">Short replace const symbols with string expressions and memorization of all search results</a><span class="tooltiptext code">template<bool UseVector>
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">141</td><td class="benchmarkresult">134</td><td class="benchmarkresult">289</td><td class="benchmarkresult">349</td><td class="benchmarkresult">553</td></tr>
|
||
</tbody></table></div><script>bench_sets['Replace symbols in text ~40 symbols'] = {id:'bs27', tests:[
|
||
{name:'Short Naive (and wrong) replace symbols with std::string find + replace',data:[150,154,305,337,866]},
|
||
{name:'Short replace symbols with std::string find_first_of + replace',data:[313,301,356,423,1328]},
|
||
{name:'Short replace symbols with std::string_view find_first_of + copy',data:[153,154,307,350,797]},
|
||
{name:'Short replace runtime symbols with string expressions and without remembering all search results',data:[172,178,259,298,656]},
|
||
{name:'Short replace runtime symbols with simstr and memorization of all search results',data:[173,192,355,396,831]},
|
||
{name:'Short replace const symbols with string expressions and without remembering all search results',data:[138,149,199,253,438]},
|
||
{name:'Short replace const symbols with string expressions and memorization of all search results',data:[141,134,289,349,553]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs28"><h4><a id="bs77745698784557935900" href="#bs77745698784557935900">#</a> Replace All Str To Longer Size</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1894">replace bb to ---- in std::string|64</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllLongerStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "----";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">157</td><td class="benchmarkresult">152</td><td class="benchmarkresult">217</td><td class="benchmarkresult">241</td><td class="benchmarkresult">754</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1894">replace bb to ---- in std::string|256</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllLongerStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "----";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">527</td><td class="benchmarkresult">463</td><td class="benchmarkresult">736</td><td class="benchmarkresult">791</td><td class="benchmarkresult">2292</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1894">replace bb to ---- in std::string|512</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllLongerStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "----";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1332</td><td class="benchmarkresult">1323</td><td class="benchmarkresult">1385</td><td class="benchmarkresult">1425</td><td class="benchmarkresult">4359</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1894">replace bb to ---- in std::string|1024</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllLongerStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "----";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">2359</td><td class="benchmarkresult">2217</td><td class="benchmarkresult">3048</td><td class="benchmarkresult">3130</td><td class="benchmarkresult">8819</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1894">replace bb to ---- in std::string|2048</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllLongerStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "----";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">5479</td><td class="benchmarkresult">5811</td><td class="benchmarkresult">7662</td><td class="benchmarkresult">7950</td><td class="benchmarkresult">18166</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1928">replace bb to ---- in lstringa<8>|64</a><span class="tooltiptext code">template<size_t N, size_t Count>
|
||
void ReplaceAllLongerSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">137</td><td class="benchmarkresult">137</td><td class="benchmarkresult">218</td><td class="benchmarkresult">234</td><td class="benchmarkresult">590</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1928">replace bb to ---- in lstringa<8>|256</a><span class="tooltiptext code">template<size_t N, size_t Count>
|
||
void ReplaceAllLongerSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">426</td><td class="benchmarkresult">451</td><td class="benchmarkresult">613</td><td class="benchmarkresult">662</td><td class="benchmarkresult">1916</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1928">replace bb to ---- in lstringa<8>|512</a><span class="tooltiptext code">template<size_t N, size_t Count>
|
||
void ReplaceAllLongerSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">781</td><td class="benchmarkresult">857</td><td class="benchmarkresult">1056</td><td class="benchmarkresult">1118</td><td class="benchmarkresult">3332</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1928">replace bb to ---- in lstringa<8>|1024</a><span class="tooltiptext code">template<size_t N, size_t Count>
|
||
void ReplaceAllLongerSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1574</td><td class="benchmarkresult">1683</td><td class="benchmarkresult">1894</td><td class="benchmarkresult">1999</td><td class="benchmarkresult">6057</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1928">replace bb to ---- in lstringa<8>|2048</a><span class="tooltiptext code">template<size_t N, size_t Count>
|
||
void ReplaceAllLongerSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">3024</td><td class="benchmarkresult">3386</td><td class="benchmarkresult">3567</td><td class="benchmarkresult">3914</td><td class="benchmarkresult">11959</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1951">replace bb to ---- by init stringa|64</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
lstringa<2048> big_source{Count, source}, big_sample{Count, sample};
|
||
|
||
for (auto _: state) {
|
||
stringa result = e_repl(big_source, "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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">91.9</td><td class="benchmarkresult">90.1</td><td class="benchmarkresult">170</td><td class="benchmarkresult">195</td><td class="benchmarkresult">403</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1951">replace bb to ---- by init stringa|256</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
lstringa<2048> big_source{Count, source}, big_sample{Count, sample};
|
||
|
||
for (auto _: state) {
|
||
stringa result = e_repl(big_source, "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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">305</td><td class="benchmarkresult">294</td><td class="benchmarkresult">369</td><td class="benchmarkresult">465</td><td class="benchmarkresult">1149</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1951">replace bb to ---- by init stringa|512</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
lstringa<2048> big_source{Count, source}, big_sample{Count, sample};
|
||
|
||
for (auto _: state) {
|
||
stringa result = e_repl(big_source, "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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">700</td><td class="benchmarkresult">673</td><td class="benchmarkresult">806</td><td class="benchmarkresult">1064</td><td class="benchmarkresult">2695</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1951">replace bb to ---- by init stringa|1024</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
lstringa<2048> big_source{Count, source}, big_sample{Count, sample};
|
||
|
||
for (auto _: state) {
|
||
stringa result = e_repl(big_source, "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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1564</td><td class="benchmarkresult">1470</td><td class="benchmarkresult">1658</td><td class="benchmarkresult">2218</td><td class="benchmarkresult">5688</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1951">replace bb to ---- by init stringa|2048</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllLongerSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa----baaaaaaaa--------aaaaabaaaaaaaaaaaaaaaaaaaaa----a";
|
||
|
||
lstringa<2048> big_source{Count, source}, big_sample{Count, sample};
|
||
|
||
for (auto _: state) {
|
||
stringa result = e_repl(big_source, "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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">3148</td><td class="benchmarkresult">2966</td><td class="benchmarkresult">3213</td><td class="benchmarkresult">4628</td><td class="benchmarkresult">11882</td></tr>
|
||
</tbody></table></div><script>bench_sets['Replace All Str To Longer Size'] = {id:'bs28', tests:[
|
||
{name:'replace bb to ---- in std::string|64',data:[157,152,217,241,754]},
|
||
{name:'replace bb to ---- in std::string|256',data:[527,463,736,791,2292]},
|
||
{name:'replace bb to ---- in std::string|512',data:[1332,1323,1385,1425,4359]},
|
||
{name:'replace bb to ---- in std::string|1024',data:[2359,2217,3048,3130,8819]},
|
||
{name:'replace bb to ---- in std::string|2048',data:[5479,5811,7662,7950,18166]},
|
||
{name:'replace bb to ---- in lstringa<8>|64',data:[137,137,218,234,590]},
|
||
{name:'replace bb to ---- in lstringa<8>|256',data:[426,451,613,662,1916]},
|
||
{name:'replace bb to ---- in lstringa<8>|512',data:[781,857,1056,1118,3332]},
|
||
{name:'replace bb to ---- in lstringa<8>|1024',data:[1574,1683,1894,1999,6057]},
|
||
{name:'replace bb to ---- in lstringa<8>|2048',data:[3024,3386,3567,3914,11959]},
|
||
{name:'replace bb to ---- by init stringa|64',data:[91.9,90.1,170,195,403]},
|
||
{name:'replace bb to ---- by init stringa|256',data:[305,294,369,465,1149]},
|
||
{name:'replace bb to ---- by init stringa|512',data:[700,673,806,1064,2695]},
|
||
{name:'replace bb to ---- by init stringa|1024',data:[1564,1470,1658,2218,5688]},
|
||
{name:'replace bb to ---- by init stringa|2048',data:[3148,2966,3213,4628,11882]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs29"><h4><a id="bs74494088982050398630" href="#bs74494088982050398630">#</a> Replace All Str To Same Size</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1973">replace bb to -- in std::string|64</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllEqualStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "--";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
for (auto _: state) {
|
||
std::string result{big_source};
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
|
||
result.replace(start_pos, pattern.length(), repl);
|
||
start_pos += repl.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result != big_sample) {
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(pattern);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">131</td><td class="benchmarkresult">113</td><td class="benchmarkresult">186</td><td class="benchmarkresult">200</td><td class="benchmarkresult">556</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1973">replace bb to -- in std::string|256</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllEqualStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "--";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
for (auto _: state) {
|
||
std::string result{big_source};
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
|
||
result.replace(start_pos, pattern.length(), repl);
|
||
start_pos += repl.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result != big_sample) {
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(pattern);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">367</td><td class="benchmarkresult">360</td><td class="benchmarkresult">464</td><td class="benchmarkresult">527</td><td class="benchmarkresult">1773</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1973">replace bb to -- in std::string|512</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllEqualStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "--";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
for (auto _: state) {
|
||
std::string result{big_source};
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
|
||
result.replace(start_pos, pattern.length(), repl);
|
||
start_pos += repl.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result != big_sample) {
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(pattern);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">722</td><td class="benchmarkresult">729</td><td class="benchmarkresult">843</td><td class="benchmarkresult">925</td><td class="benchmarkresult">3125</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1973">replace bb to -- in std::string|1024</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllEqualStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "--";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
for (auto _: state) {
|
||
std::string result{big_source};
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
|
||
result.replace(start_pos, pattern.length(), repl);
|
||
start_pos += repl.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result != big_sample) {
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(pattern);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1429</td><td class="benchmarkresult">1303</td><td class="benchmarkresult">1576</td><td class="benchmarkresult">1849</td><td class="benchmarkresult">6361</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L1973">replace bb to -- in std::string|2048</a><span class="tooltiptext code">template<size_t Long>
|
||
void ReplaceAllEqualStdString(benchmark::State& state) {
|
||
std::string_view source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
std::string_view sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
std::string_view pattern = "bb";
|
||
std::string_view repl = "--";
|
||
|
||
std::string big_source, big_sample;
|
||
for (int i = 0; i < Long; i++) {
|
||
big_source += source;
|
||
big_sample += sample;
|
||
}
|
||
|
||
for (auto _: state) {
|
||
std::string result{big_source};
|
||
size_t start_pos = 0;
|
||
while((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
|
||
result.replace(start_pos, pattern.length(), repl);
|
||
start_pos += repl.length();
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (result != big_sample) {
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
benchmark::DoNotOptimize(pattern);
|
||
benchmark::DoNotOptimize(repl);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">2801</td><td class="benchmarkresult">2642</td><td class="benchmarkresult">3142</td><td class="benchmarkresult">3432</td><td class="benchmarkresult">11893</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2006">replace bb to -- in lstringa<8>|64</a><span class="tooltiptext code">template<size_t N, size_t Long>
|
||
void ReplaceAllEqualSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
lstringa<2048> big_source{Long, source}, big_sample{Long, sample};
|
||
|
||
for (auto _: state) {
|
||
lstringa<N> result = big_source;
|
||
result.replace("bb", "--");
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result.to_str() != big_sample) {
|
||
std::cout << result.length() << ": " << result << "\n\n" << big_sample.length() << ": " << big_sample << "\n\n";
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">99.6</td><td class="benchmarkresult">93.3</td><td class="benchmarkresult">185</td><td class="benchmarkresult">184</td><td class="benchmarkresult">439</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2006">replace bb to -- in lstringa<8>|256</a><span class="tooltiptext code">template<size_t N, size_t Long>
|
||
void ReplaceAllEqualSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
lstringa<2048> big_source{Long, source}, big_sample{Long, sample};
|
||
|
||
for (auto _: state) {
|
||
lstringa<N> result = big_source;
|
||
result.replace("bb", "--");
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result.to_str() != big_sample) {
|
||
std::cout << result.length() << ": " << result << "\n\n" << big_sample.length() << ": " << big_sample << "\n\n";
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">289</td><td class="benchmarkresult">284</td><td class="benchmarkresult">423</td><td class="benchmarkresult">441</td><td class="benchmarkresult">1355</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2006">replace bb to -- in lstringa<8>|512</a><span class="tooltiptext code">template<size_t N, size_t Long>
|
||
void ReplaceAllEqualSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
lstringa<2048> big_source{Long, source}, big_sample{Long, sample};
|
||
|
||
for (auto _: state) {
|
||
lstringa<N> result = big_source;
|
||
result.replace("bb", "--");
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result.to_str() != big_sample) {
|
||
std::cout << result.length() << ": " << result << "\n\n" << big_sample.length() << ": " << big_sample << "\n\n";
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">523</td><td class="benchmarkresult">517</td><td class="benchmarkresult">728</td><td class="benchmarkresult">773</td><td class="benchmarkresult">2540</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2006">replace bb to -- in lstringa<8>|1024</a><span class="tooltiptext code">template<size_t N, size_t Long>
|
||
void ReplaceAllEqualSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
lstringa<2048> big_source{Long, source}, big_sample{Long, sample};
|
||
|
||
for (auto _: state) {
|
||
lstringa<N> result = big_source;
|
||
result.replace("bb", "--");
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result.to_str() != big_sample) {
|
||
std::cout << result.length() << ": " << result << "\n\n" << big_sample.length() << ": " << big_sample << "\n\n";
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1058</td><td class="benchmarkresult">1029</td><td class="benchmarkresult">1403</td><td class="benchmarkresult">1438</td><td class="benchmarkresult">4650</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2006">replace bb to -- in lstringa<8>|2048</a><span class="tooltiptext code">template<size_t N, size_t Long>
|
||
void ReplaceAllEqualSimString(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
lstringa<2048> big_source{Long, source}, big_sample{Long, sample};
|
||
|
||
for (auto _: state) {
|
||
lstringa<N> result = big_source;
|
||
result.replace("bb", "--");
|
||
|
||
#ifdef CHECK_RESULT
|
||
if (result.to_str() != big_sample) {
|
||
std::cout << result.length() << ": " << result << "\n\n" << big_sample.length() << ": " << big_sample << "\n\n";
|
||
state.SkipWithError("error in replace");
|
||
break;
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(result);
|
||
benchmark::DoNotOptimize(source);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">2093</td><td class="benchmarkresult">2035</td><td class="benchmarkresult">2686</td><td class="benchmarkresult">2797</td><td class="benchmarkresult">9148</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2028">replace bb to -- by init stringa|64</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
ssa pattern = "bb";
|
||
ssa repl = "--";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">74.4</td><td class="benchmarkresult">83.5</td><td class="benchmarkresult">151</td><td class="benchmarkresult">165</td><td class="benchmarkresult">309</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2028">replace bb to -- by init stringa|256</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
ssa pattern = "bb";
|
||
ssa repl = "--";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">238</td><td class="benchmarkresult">263</td><td class="benchmarkresult">320</td><td class="benchmarkresult">371</td><td class="benchmarkresult">967</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2028">replace bb to -- by init stringa|512</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
ssa pattern = "bb";
|
||
ssa repl = "--";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">420</td><td class="benchmarkresult">516</td><td class="benchmarkresult">523</td><td class="benchmarkresult">613</td><td class="benchmarkresult">1774</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2028">replace bb to -- by init stringa|1024</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
ssa pattern = "bb";
|
||
ssa repl = "--";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">869</td><td class="benchmarkresult">999</td><td class="benchmarkresult">978</td><td class="benchmarkresult">1103</td><td class="benchmarkresult">3375</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2028">replace bb to -- by init stringa|2048</a><span class="tooltiptext code">template<size_t Count>
|
||
void ReplaceAllEqualSimStringExpr(benchmark::State& state) {
|
||
ssa source = "aaaaaaaaaaaaaaaaaaabbbaaaaaaaabbbbaaaaabaaaaaaaaaaaaaaaaaaaaabba";
|
||
ssa sample = "aaaaaaaaaaaaaaaaaaa--baaaaaaaa----aaaaabaaaaaaaaaaaaaaaaaaaaa--a";
|
||
ssa pattern = "bb";
|
||
ssa repl = "--";
|
||
|
||
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);
|
||
}
|
||
}</span></span></td><td></td><td class="benchmarkresult">1707</td><td class="benchmarkresult">1966</td><td class="benchmarkresult">1763</td><td class="benchmarkresult">2080</td><td class="benchmarkresult">6646</td></tr>
|
||
</tbody></table></div><script>bench_sets['Replace All Str To Same Size'] = {id:'bs29', tests:[
|
||
{name:'replace bb to -- in std::string|64',data:[131,113,186,200,556]},
|
||
{name:'replace bb to -- in std::string|256',data:[367,360,464,527,1773]},
|
||
{name:'replace bb to -- in std::string|512',data:[722,729,843,925,3125]},
|
||
{name:'replace bb to -- in std::string|1024',data:[1429,1303,1576,1849,6361]},
|
||
{name:'replace bb to -- in std::string|2048',data:[2801,2642,3142,3432,11893]},
|
||
{name:'replace bb to -- in lstringa<8>|64',data:[99.6,93.3,185,184,439]},
|
||
{name:'replace bb to -- in lstringa<8>|256',data:[289,284,423,441,1355]},
|
||
{name:'replace bb to -- in lstringa<8>|512',data:[523,517,728,773,2540]},
|
||
{name:'replace bb to -- in lstringa<8>|1024',data:[1058,1029,1403,1438,4650]},
|
||
{name:'replace bb to -- in lstringa<8>|2048',data:[2093,2035,2686,2797,9148]},
|
||
{name:'replace bb to -- by init stringa|64',data:[74.4,83.5,151,165,309]},
|
||
{name:'replace bb to -- by init stringa|256',data:[238,263,320,371,967]},
|
||
{name:'replace bb to -- by init stringa|512',data:[420,516,523,613,1774]},
|
||
{name:'replace bb to -- by init stringa|1024',data:[869,999,978,1103,3375]},
|
||
{name:'replace bb to -- by init stringa|2048',data:[1707,1966,1763,2080,6646]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs30"><h4><a id="bs8410196985047277720" href="#bs8410196985047277720">#</a> Hash Map insert and find</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2125">hashStrMapA<size_t> emplace & find stringa;</a><span class="tooltiptext code">void HashMapSimStr(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
hashStrMapA<size_t> store;
|
||
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
|
||
store.try_emplace(bs_sim[idx], idx);
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (store.size() != bs_sim.size()) {
|
||
state.SkipWithError("bad inserts");
|
||
}
|
||
#endif
|
||
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
|
||
auto find = store.find(bs_sim[idx]);
|
||
size_t res = find->second;
|
||
#ifdef CHECK_RESULT
|
||
if (res != idx) {
|
||
state.SkipWithError("bad find");
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Вставляем в hashStrMapA 10000 stringa длиной от 30 до 50
|
||
символов, а потом ищем их в ней
|
||
We insert 10,000 strings of length from 30 to 50 characters into
|
||
hashStrMapA, and then search for them in it.</span></span></td><td class="benchmarkresult">3519614</td><td class="benchmarkresult">3793699</td><td class="benchmarkresult">3922015</td><td class="benchmarkresult">4404870</td><td class="benchmarkresult">5122075</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2149">std::unordered_map<std::string, size_t> emplace & find std::string;</a><span class="tooltiptext code">void HashMapStdStr(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">То же самое c std::string и std::unordered_map
|
||
Same thing with std::string and std::unordered_map</span></span></td><td class="benchmarkresult">3429563</td><td class="benchmarkresult">3632923</td><td class="benchmarkresult">5584695</td><td class="benchmarkresult">5721296</td><td class="benchmarkresult">6141653</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2173">hashStrMapA<size_t> emplace & find ssa;</a><span class="tooltiptext code">void HashMapSimSsa(benchmark::State& state) {
|
||
for (auto _: state) {
|
||
hashStrMapA<size_t> store;
|
||
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
|
||
store.emplace(bs_sim[idx], idx);
|
||
}
|
||
#ifdef CHECK_RESULT
|
||
if (store.size() != bs_sim.size()) {
|
||
state.SkipWithError("bad inserts");
|
||
}
|
||
#endif
|
||
for (size_t idx = 0; idx < bs_sim.size(); idx++) {
|
||
ssa key = bs_sim[idx];
|
||
auto find = store.find(key);
|
||
size_t res = find->second;
|
||
#ifdef CHECK_RESULT
|
||
if (res != idx) {
|
||
state.SkipWithError("bad find");
|
||
}
|
||
#endif
|
||
benchmark::DoNotOptimize(res);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Теперь вставляем stringa, а ищем ssa
|
||
Now we insert stringa and search for ssa</span></span></td><td class="benchmarkresult">3526598</td><td class="benchmarkresult">3697109</td><td class="benchmarkresult">3523219</td><td class="benchmarkresult">3899002</td><td class="benchmarkresult">5107848</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2198">std::unordered_map<std::string, size_t> emplace & find std::string_view;</a><span class="tooltiptext code">void HashMapStdStrView(benchmark::State& state) {
|
||
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);
|
||
}
|
||
}
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Вставляем std::string, а ищем std::string_view
|
||
We insert std::string and look for std::string_view</span></span></td><td class="benchmarkresult">4067399</td><td class="benchmarkresult">3939262</td><td class="benchmarkresult">6362266</td><td class="benchmarkresult">6299827</td><td class="benchmarkresult">7187813</td></tr>
|
||
</tbody></table></div><script>bench_sets['Hash Map insert and find'] = {id:'bs30', tests:[
|
||
{name:'hashStrMapA<size_t> emplace & find stringa;',data:[3519614,3793699,3922015,4404870,5122075]},
|
||
{name:'std::unordered_map<std::string, size_t> emplace & find std::string;',data:[3429563,3632923,5584695,5721296,6141653]},
|
||
{name:'hashStrMapA<size_t> emplace & find ssa;',data:[3526598,3697109,3523219,3899002,5107848]},
|
||
{name:'std::unordered_map<std::string, size_t> emplace & find std::string_view;',data:[4067399,3939262,6362266,6299827,7187813]}
|
||
]}</script>
|
||
|
||
<div class="benchset" id="bs31"><h4><a id="bs131384792586914680410" href="#bs131384792586914680410">#</a> Build Full Func Name</h4>
|
||
<table><thead><tr><th>Benchmark name</th><th width="5%">Comment</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21</th><th width="8%">Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13</th><th width="8%">Xeon E5-2682 v4, Windows 10, Clang-19</th><th width="8%">Xeon E5-2682 v4, Windows 10, MSVC-19</th><th width="8%">Xeon E5-2682 v4, WASM Chrome 143, Clang-21</th></tr></thead><tbody>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2408">Build func full name std::string;</a><span class="tooltiptext code">std::string build_full_name_std() const {
|
||
std::string str{has_ret_type_resolver ? "any"sv : type_names_sv[(unsigned)ret_type]};
|
||
str += " ";
|
||
str += std_name;
|
||
str += "(";
|
||
|
||
bool add_comma = false;
|
||
|
||
for (const auto& param : params) {
|
||
if (add_comma) {
|
||
str += ", ";
|
||
}
|
||
if (param.optional) {
|
||
str += "[";
|
||
}
|
||
param.allowed_types.to_stdstr(str);
|
||
if (param.optional) {
|
||
str += "]";
|
||
}
|
||
add_comma = true;
|
||
}
|
||
if (unlim_params) {
|
||
if (add_comma) {
|
||
str += ", ";
|
||
}
|
||
str += "...";
|
||
}
|
||
str += ")";
|
||
//std::cout << "Len=" << str.length() << ", Cap=" << str.capacity() << "\n";
|
||
return str;
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Обыденная задача, подобные часто могут встретится в работе:
|
||
По неким данным сгенерировать текст. В этом случае по данным
|
||
о неких функциях сформировать их полное имя с типами параметров и
|
||
возвращаемого значения. Алгоритм на std::string.
|
||
A common task, similar to this one, can often be encountered in work:
|
||
Generate text from given data. In this case, using data
|
||
on certain functions, generate their full names with parameter types and
|
||
return values. The algorithm uses std::string.</span></span></td><td class="benchmarkresult">660</td><td class="benchmarkresult">812</td><td class="benchmarkresult">1505</td><td class="benchmarkresult">1577</td><td class="benchmarkresult">5362</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2440">Build func full name std::string 1;</a><span class="tooltiptext code">std::string build_full_name_std1() const {
|
||
std::string str{has_ret_type_resolver ? "any"sv : type_names_sv[(unsigned)ret_type]};
|
||
str += " " + std_name + "(";
|
||
|
||
bool add_comma = false;
|
||
|
||
for (const auto& param : params) {
|
||
if (add_comma) {
|
||
str += ", ";
|
||
}
|
||
if (param.optional) {
|
||
str += "[";
|
||
}
|
||
param.allowed_types.to_stdstr(str);
|
||
if (param.optional) {
|
||
str += "]";
|
||
}
|
||
add_comma = true;
|
||
}
|
||
if (unlim_params) {
|
||
if (add_comma) {
|
||
str += ", ";
|
||
}
|
||
str += "...";
|
||
}
|
||
str += ")";
|
||
//std::cout << "Len=" << str.length() << ", Cap=" << str.capacity() << "\n";
|
||
return str;
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Почти тот же алгоритм, но несколько последовательных
|
||
+= к строке заменены на одно += + + +.
|
||
Almost the same algorithm, but several consecutive
|
||
+= to a string are replaced with a single += + + +.</span></span></td><td class="benchmarkresult">758</td><td class="benchmarkresult">935</td><td class="benchmarkresult">1501</td><td class="benchmarkresult">1622</td><td class="benchmarkresult">6029</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2470">Build func full name std::stream;</a><span class="tooltiptext code">std::string build_full_name_stream() const {
|
||
std::ostringstream str;
|
||
if (has_ret_type_resolver) {
|
||
str << "any";
|
||
} else {
|
||
str << type_names_sv[(unsigned)ret_type];
|
||
}
|
||
str << " " << std_name << "(";
|
||
|
||
bool add_comma = false;
|
||
|
||
for (const auto& param : params) {
|
||
if (add_comma) {
|
||
str << ", ";
|
||
}
|
||
if (param.optional) {
|
||
str << "[";
|
||
}
|
||
param.allowed_types.to_stream(str);
|
||
if (param.optional) {
|
||
str << "]";
|
||
}
|
||
add_comma = true;
|
||
}
|
||
if (unlim_params) {
|
||
if (add_comma) {
|
||
str << ", ";
|
||
}
|
||
str << "...";
|
||
}
|
||
str << ")";
|
||
return str.str();
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Строим имя функции через std::ostringstream и <<
|
||
We construct the function name through std::ostringstream and <<</span></span></td><td class="benchmarkresult">2557</td><td class="benchmarkresult">2527</td><td class="benchmarkresult">8093</td><td class="benchmarkresult">9579</td><td class="benchmarkresult">25412</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2381">Build func full name stringa;</a><span class="tooltiptext code">stringa build_full_name() const {
|
||
lstringa<512> str = e_choice(has_ret_type_resolver, "any", type_names[(unsigned)ret_type]) + " " + name + "(";
|
||
|
||
bool add_comma = false;
|
||
|
||
for (const auto& param : params) {
|
||
str += e_if(add_comma, ", ") + e_if(param.optional, "[");
|
||
param.allowed_types.to_simstr(str);
|
||
if (param.optional) {
|
||
str += "]";
|
||
}
|
||
add_comma = true;
|
||
}
|
||
return str + e_if(unlim_params, e_if(add_comma, ", ") + "...") + ")";
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Реализация на simstr строках и строковых выражениях.
|
||
Инфа о параметрах добавляется в текущую строку
|
||
Implementation using simstr strings and string expressions.
|
||
Parameter information is appended to the current line.</span></span></td><td class="benchmarkresult">494</td><td class="benchmarkresult">446</td><td class="benchmarkresult">747</td><td class="benchmarkresult">857</td><td class="benchmarkresult">2926</td></tr>
|
||
<tr><td class="benchmarkname"><span class="tooltip"><a target="blank" href="https://github.com/orefkov/simstr/blob/rel1.6.7/bench/bench_str.cpp#L2396">Build func full name stringa 1;</a><span class="tooltiptext code">stringa build_full_name1() const {
|
||
lstringa<512> str = e_choice(has_ret_type_resolver, "any", type_names[(unsigned)ret_type]) + " " + name + "(";
|
||
|
||
bool add_comma = false;
|
||
|
||
for (const auto& param : params) {
|
||
str += e_if(add_comma, ", ") + e_if(param.optional, "[") + param.allowed_types.get_simstr() + e_if(param.optional, "]");
|
||
add_comma = true;
|
||
}
|
||
return str + e_if(unlim_params, e_if(add_comma, ", ") + "...") + ")";
|
||
}</span></span></td><td><span class="tooltip info"> >> <span class="tooltiptext">Реализация на simstr строках и строковых выражениях.
|
||
Инфа о параметрах добавляется во временную строку, а потом
|
||
разом добавляется в текущую строку. Позволяет операции в цикле
|
||
записать в одну строку, но чуть проигрывает по времени выполнения.
|
||
Implementation using simstr strings and string expressions.
|
||
Parameter information is added to a temporary string, and then
|
||
all at once to the current string. This allows loop operations
|
||
to be written in a single string, but is slightly slower in execution time.</span></span></td><td class="benchmarkresult">607</td><td class="benchmarkresult">624</td><td class="benchmarkresult">898</td><td class="benchmarkresult">1025</td><td class="benchmarkresult">3417</td></tr>
|
||
</tbody></table></div><script>bench_sets['Build Full Func Name'] = {id:'bs31', tests:[
|
||
{name:'Build func full name std::string;',data:[660,812,1505,1577,5362]},
|
||
{name:'Build func full name std::string 1;',data:[758,935,1501,1622,6029]},
|
||
{name:'Build func full name std::stream;',data:[2557,2527,8093,9579,25412]},
|
||
{name:'Build func full name stringa;',data:[494,446,747,857,2926]},
|
||
{name:'Build func full name stringa 1;',data:[607,624,898,1025,3417]}
|
||
]}</script></body></html> |