Skip to content

Commit ad3a452

Browse files
committed
- Update to 1.6.4
- Add operator""_fmt for integer format.
1 parent c0dfdd4 commit ad3a452

19 files changed

Lines changed: 5373 additions & 5067 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(FetchContent)
55

66
project(
77
simstr
8-
VERSION 1.6.3
8+
VERSION 1.6.4
99
DESCRIPTION "Yet another modern C++ string library"
1010
HOMEPAGE_URL "https://github.com/orefkov/simstr"
1111
LANGUAGES CXX

bench/bench_str.cpp

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sstream>
88
#include <string>
99
#include <charconv>
10+
#include <iomanip>
1011

1112
using namespace simstr;
1213
using namespace std::literals;
@@ -183,17 +184,25 @@ BENCHMARK(ConcatSimToSimHexC) ->Name("Concat stringa and hex number and litera
183184
BENCHMARK(ConcatSimToSimHexS) ->Name("Subst stringa and hex number by e_subst literal to simstr::stringa");
184185
BENCHMARK(ConcatSimToSimHexVS) ->Name("Subst stringa and hex number by e_vsubst stra to simstr::stringa");
185186

186-
void SubstSimToSimBin(benchmark::State& state) {
187-
static bool first = true;
187+
void ConcatSimToSimOct(benchmark::State& state) {
188188
for (auto _: state) {
189189
for (unsigned i = 1; i <= 100'000; i *= 10) {
190-
stringa str = e_subst("art {} end", e_int<8, f::w<10> | f::p | f::z>(i));
190+
stringa str = "art "_ss + i / 0x8a010_fmt + " end";
191191
benchmark::DoNotOptimize(str);
192192
}
193193
}
194194
}
195195

196-
void FormatStdToStdBin(benchmark::State& state) {
196+
void SubstSimToSimOct(benchmark::State& state) {
197+
for (auto _: state) {
198+
for (unsigned i = 1; i <= 100'000; i *= 10) {
199+
stringa str = e_subst("art {} end", i / 0x8a010_fmt);
200+
benchmark::DoNotOptimize(str);
201+
}
202+
}
203+
}
204+
205+
void FormatStdToStdOct(benchmark::State& state) {
197206
for (auto _: state) {
198207
for (unsigned i = 1; i <= 100'000; i *= 10) {
199208
std::string str = std::format("art {:#010o} end", i);
@@ -202,31 +211,44 @@ void FormatStdToStdBin(benchmark::State& state) {
202211
}
203212
}
204213

205-
void VSubstSimToSimBin(benchmark::State& state) {
214+
void VSubstSimToSimOct(benchmark::State& state) {
206215
ssa pattern = "art {} end";
207216
for (auto _: state) {
208217
for (unsigned i = 1; i <= 100'000; i *= 10) {
209-
stringa str = e_vsubst(pattern, e_int<8, f::w<10> | f::p | f::z>(i));
218+
stringa str = e_vsubst(pattern, i / 0x8a010_fmt);
210219
benchmark::DoNotOptimize(str);
211220
}
212221
}
213222
}
214223

215-
void VFormatStdToStdBin(benchmark::State& state) {
224+
void VFormatStdToStdOct(benchmark::State& state) {
216225
std::string_view pattern = "art {:#010o} end";
217-
static bool first = true;
218226
for (auto _: state) {
219227
for (unsigned i = 1; i <= 100'000; i *= 10) {
220228
std::string str = std::vformat(pattern, std::make_format_args(i));
221229
benchmark::DoNotOptimize(str);
222230
}
223231
}
224232
}
233+
234+
void StreamStdToStdOct(benchmark::State& state) {
235+
for (auto _: state) {
236+
for (unsigned i = 1; i <= 100'000; i *= 10) {
237+
std::stringstream strm;
238+
strm << "art 0" << std::oct << std::setw(9) << std::setfill('0') << i << " end";
239+
std::string str = strm.str();
240+
benchmark::DoNotOptimize(str);
241+
}
242+
}
243+
}
244+
225245
BENCHMARK(__)->Name("----- format/vformat and subst/vsubst octal number ---------")->Repetitions(1);
226-
BENCHMARK(SubstSimToSimBin) ->Name("e_subst(\"art {} end\", e_int<8, f::w<10> | f::p | f::z>(i))");
227-
BENCHMARK(FormatStdToStdBin) ->Name("std::format(\"art {:#010o} end\", i)");
228-
BENCHMARK(VSubstSimToSimBin) ->Name("e_vsubst(pattern, e_int<8, f::w<10> | f::p | f::z>(i))");
229-
BENCHMARK(VFormatStdToStdBin) ->Name("std::vformat(pattern, std::make_format_args(i))");
246+
BENCHMARK(ConcatSimToSimOct) ->Name("\"art \"_ss + i / 0x8a010_fmt + \" end\"");
247+
BENCHMARK(SubstSimToSimOct) ->Name("e_subst(\"art {} end\", i / 0x8a010_fmt)");
248+
BENCHMARK(VSubstSimToSimOct) ->Name("e_vsubst(pattern, i / 0x8a010_fmt)");
249+
BENCHMARK(FormatStdToStdOct) ->Name("std::format(\"art {:#010o} end\", i)");
250+
BENCHMARK(VFormatStdToStdOct) ->Name("std::vformat(pattern, std::make_format_args(i))");
251+
BENCHMARK(StreamStdToStdOct) ->Name("strm << \"art 0\" << std::oct << std::setw(9) << std::setfill('0') << i << \" end\"");
230252

231253
void ConcatStdToStdS(benchmark::State& state) {
232254
std::string s1 = "start ";

bench/results.html

Lines changed: 682 additions & 664 deletions
Large diffs are not rendered by default.

bench/results/000-Xeon E5-2682 v4, Ubuntu 22 (WSL), Clang-21.txt

Lines changed: 873 additions & 865 deletions
Large diffs are not rendered by default.

bench/results/001-Xeon E5-2682 v4, Ubuntu 22 (WSL), GCC-13.txt

Lines changed: 875 additions & 867 deletions
Large diffs are not rendered by default.

bench/results/002-Xeon E5-2682 v4, Windows 10, Clang-19.txt

Lines changed: 867 additions & 859 deletions
Large diffs are not rendered by default.

bench/results/003-Xeon E5-2682 v4, Windows 10, MSVC-19.txt

Lines changed: 879 additions & 871 deletions
Large diffs are not rendered by default.

bench/results/004-Xeon E5-2682 v4, WASM Firefox, Clang-21.txt

Lines changed: 874 additions & 866 deletions
Large diffs are not rendered by default.

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 1.6.3
51+
PROJECT_NUMBER = 1.6.4
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewers a

docs/Doxyfile_ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 1.6.3
51+
PROJECT_NUMBER = 1.6.4
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewers a

0 commit comments

Comments
 (0)