Skip to content

Commit c3d3c60

Browse files
committed
Testing with bnch_swt::random_generator.
1 parent 0b59931 commit c3d3c60

File tree

4 files changed

+68
-114
lines changed

4 files changed

+68
-114
lines changed

.github/workflows/Benchmark.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
git commit -m "Updates - MSVC-Windows"
6262
git push -f https://${{ secrets.GITHUB_TOKEN }}@github.com/RealTimeChris/Json-Performance.git temp-msvc-windows
6363
64-
Build-GNUCXX-Ubuntu:
64+
Build-GCC-Ubuntu:
6565
runs-on: ubuntu-latest
6666

6767
strategy:
@@ -113,7 +113,7 @@ jobs:
113113
sudo git config --global user.name "RealTimeChris"
114114
sudo git checkout -b temp-gnucxx-ubuntu
115115
sudo git add .
116-
sudo git commit -m "Updates - GNUCXX-Ubuntu"
116+
sudo git commit -m "Updates - GCC-Ubuntu"
117117
sudo git push -f https://${{ secrets.GITHUB_TOKEN }}@github.com/RealTimeChris/Json-Performance.git temp-gnucxx-ubuntu
118118
119119
Build-CLANG-Ubuntu:
@@ -172,7 +172,7 @@ jobs:
172172
sudo git commit -m "Updates - CLANG-Ubuntu"
173173
sudo git push -f https://${{ secrets.GITHUB_TOKEN }}@github.com/RealTimeChris/Json-Performance.git temp-clang-ubuntu
174174
175-
Build-GNUCXX-MacOS:
175+
Build-GCC-MacOS:
176176
runs-on: macos-latest
177177
strategy:
178178
fail-fast: false
@@ -248,7 +248,7 @@ jobs:
248248
sudo git config --global user.name "RealTimeChris"
249249
sudo git checkout -b temp-gnucxx-macos
250250
sudo git add .
251-
sudo git commit -m "Updates - GNUCXX-MacOS"
251+
sudo git commit -m "Updates - GCC-MacOS"
252252
sudo git push -f https://${{ secrets.GITHUB_TOKEN }}@github.com/RealTimeChris/Json-Performance.git temp-gnucxx-macos
253253
254254
Build-CLANG-MacOS:
@@ -322,9 +322,9 @@ jobs:
322322
runs-on: ubuntu-latest
323323
needs:
324324
- Build-MSVC-Windows
325-
- Build-GNUCXX-Ubuntu
325+
- Build-GCC-Ubuntu
326326
- Build-CLANG-Ubuntu
327-
- Build-GNUCXX-MacOS
327+
- Build-GCC-MacOS
328328
- Build-CLANG-MacOS
329329

330330
steps:

ReadMe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Here's a few benchmarks on a few common operating system/compiler platforms. Alt
1212
#### Microsoft Windows/MSVC:
1313
----
1414
[![MSVC/Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=Microsoft&logoColor=green&label=MSVC&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/Windows-MSVC.md)
15-
#### Ubuntu Linux/GNUCXX:
15+
#### Ubuntu Linux/GCC:
1616
----
17-
[![GNUCXX/Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=linux&logoColor=green&label=GNUCXX&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/Ubuntu-GNUCXX.md)
17+
[![GCC/Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=linux&logoColor=green&label=GCC&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/Ubuntu-GCC.md)
1818
#### MacOS/CLANG:
1919
----
2020
[![CLANG/MacOS](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=apple&logoColor=green&label=CLANG&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/MacOS-CLANG.md)
21-
#### MacOS/GNUCXX:
21+
#### MacOS/GCC:
2222
----
23-
[![GNUCXX/MacOS](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=apple&logoColor=green&label=GNUCXX&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/MacOS-GNUCXX.md)
23+
[![GCC/MacOS](https://img.shields.io/github/actions/workflow/status/RealTimeChris/Json-Performance/Benchmark.yml?style=plastic&logo=apple&logoColor=green&label=GCC&labelColor=pewter&color=blue&branch=benchmarking-newer)](https://github.com/RealTimeChris/Json-Performance/blob/main/MacOS-GCC.md)
2424

2525
### Pre-requisites:
2626
---

Source/Common.hpp

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ constexpr auto getCurrentCompilerId() {
5959
constexpr auto osCompilerIdNew = bnch_swt::internal::to_lower(compilerId);
6060
if constexpr (osCompilerIdNew.operator std::string_view().contains("gnu") || osCompilerIdNew.operator std::string_view().contains("gcc") ||
6161
osCompilerIdNew.operator std::string_view().contains("g++")) {
62-
return bnch_swt::string_literal{ "GNUCXX" };
62+
return bnch_swt::string_literal{ "GCC" };
6363
} else if constexpr (osCompilerIdNew.operator std::string_view().contains("clang") || osCompilerIdNew.operator std::string_view().contains("appleclang")) {
6464
return bnch_swt::string_literal{ "CLANG" };
6565
} else if constexpr (osCompilerIdNew.operator std::string_view().contains("msvc")) {
@@ -144,7 +144,7 @@ std::string getCPUInfo() {
144144
}
145145

146146
void executePythonScript(const std::string& scriptPath, const std::string& argument01, const std::string& argument02) {
147-
#if JSONIFIER_PLATFORM_WINDOWS
147+
#if defined(JSONIFIER_WIN)
148148
static std::string pythonName{ "python " };
149149
#else
150150
static std::string pythonName{ "python3 " };
@@ -186,75 +186,29 @@ template<typename value_type> struct partial_test {
186186
};
187187

188188
struct test_generator {
189-
static constexpr std::string_view charSet{ "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~!#$%&'()*+,-./"
190-
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~!#$%&'()*+,-./"
191-
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~!#$%&'()*+,-./"
192-
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~\"\\\b\f\n\r\t" };
193-
inline static std::uniform_real_distribution<double> disDouble{ log(std::numeric_limits<double>::min()), log(std::numeric_limits<double>::max()) };
194-
inline static std::uniform_int_distribution<int64_t> disInt{ std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max() };
195-
inline static std::uniform_int_distribution<uint64_t> disUint{ std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max() };
196-
inline static std::uniform_int_distribution<uint64_t> disCharSet{ 0ull, charSet.size() - 1 };
197-
inline static std::uniform_int_distribution<uint64_t> disString{ 16ull, 64ull };
198-
inline static std::uniform_int_distribution<uint64_t> disUnicodeEmoji{ 0ull, std::size(unicode_emoji::unicodeEmoji) - 1 };
199-
inline static std::uniform_int_distribution<uint64_t> disBool{ 0, 100 };
200-
inline static std::random_device randomEngine{};
201-
inline static std::mt19937_64 gen{ randomEngine() };
202-
203-
template<jsonifier::concepts::integer_t value_type01, jsonifier::concepts::integer_t value_type02>
204-
static value_type01 randomizeNumberUniform(value_type01 start, value_type02 end) {
205-
std::uniform_int_distribution<value_type01> dis{ start, static_cast<value_type01>(end) };
206-
return dis(gen);
207-
}
208-
209189
template<jsonifier::concepts::string_t value_type> static value_type generateValue() {
210-
auto length{ disString(gen) };
211-
212-
std::string result{};
213-
for (uint64_t x = 0; x < length; ++x) {
214-
result += charSet[disCharSet(gen)];
215-
}
216-
217-
return result;
190+
return bnch_swt::random_generator<std::string>::impl(bnch_swt::random_generator<uint64_t>::impl(16ull, 64ull));
218191
}
219192

220193
template<jsonifier::concepts::float_t value_type> static value_type generateValue() {
221-
double logValue = disDouble(gen);
222-
bool negative{ generateValue<bool>() };
223-
return negative ? -std::exp(logValue) : std::exp(logValue);
194+
return bnch_swt::random_generator<double>::impl();
224195
}
225196

226197
template<jsonifier::concepts::bool_t value_type> static value_type generateValue() {
227-
return static_cast<bool>(disBool(gen) >= 50);
198+
return bnch_swt::random_generator<bool>::impl();
228199
}
229200

230201
template<jsonifier::concepts::uns64_t value_type> static value_type generateValue() {
231-
size_t length{ randomizeNumberUniform(1ull, 20ull) };
232-
233-
uint64_t min_val = (length == 1) ? 0 : static_cast<uint64_t>(std::pow(10, length - 1));
234-
uint64_t max_val = static_cast<uint64_t>(std::pow(10, length)) - 1;
235-
if (min_val > max_val) {
236-
std::swap(min_val, max_val);
237-
}
238-
std::uniform_int_distribution<uint64_t> dis(min_val, max_val);
239-
return dis(gen);
202+
return bnch_swt::random_generator<uint64_t>::impl();
240203
}
241204

242205
template<jsonifier::concepts::sig64_t value_type> static value_type generateValue() {
243-
size_t length{ randomizeNumberUniform(1ull, 19ull) };
244-
245-
int64_t min_val = (length == 1) ? 0 : static_cast<int64_t>(std::pow(10, length - 1));
246-
int64_t max_val = static_cast<int64_t>(std::pow(10, length)) - 1;
247-
if (min_val > max_val) {
248-
std::swap(min_val, max_val);
249-
}
250-
std::uniform_int_distribution<int64_t> dis(min_val, max_val);
251-
auto returnValue{ dis(gen) };
252-
return generateValue<bool>() ? returnValue : -returnValue;
206+
return bnch_swt::random_generator<int64_t>::impl();
253207
}
254208

255209
static test_struct generateTestStruct() {
256210
test_struct returnValues{};
257-
returnValues.testBool = generateValue<bool>();
211+
returnValues.testBool = generateValue<bool>();
258212
returnValues.testDouble = generateValue<double>();
259213
returnValues.testInt = generateValue<int64_t>();
260214
returnValues.testUint = generateValue<uint64_t>();
@@ -276,7 +230,7 @@ struct test_generator {
276230
static test<test_struct> generateTest() {
277231
test<test_struct> returnValues{};
278232
auto fill = [&](auto& v) {
279-
const auto arraySize01 = randomizeNumberUniform(1ull, 15ull);
233+
const auto arraySize01 = bnch_swt::random_generator<uint64_t>::impl(1ull, 15ull);
280234
v.resize(arraySize01);
281235
for (uint64_t x = 0; x < arraySize01; ++x) {
282236
v[x] = generateTestStruct();
@@ -459,7 +413,7 @@ struct test_results {
459413
};
460414

461415
std::tm getTime() {
462-
#if JSONIFIER_PLATFORM_WINDOWS
416+
#if defined(JSONIFIER_WIN)
463417
std::time_t result = std::time(nullptr);
464418
std::tm resultTwo{};
465419
localtime_s(&resultTwo, &result);

0 commit comments

Comments
 (0)