summaryrefslogtreecommitdiffhomepage
path: root/benchmarks/misc/prng_bench.cpp
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-05-10 08:58:04 +0200
committerTyge Lovset <[email protected]>2022-05-10 08:58:04 +0200
commit649060e1275f04985ded4b324ae8e2b004788e78 (patch)
treed7d30631cc247ea60b65be78afe8b20a18f3ef43 /benchmarks/misc/prng_bench.cpp
parent973cdf51cbc10bcd6749763aec007f3730884a2d (diff)
downloadSTC-modified-649060e1275f04985ded4b324ae8e2b004788e78.tar.gz
STC-modified-649060e1275f04985ded4b324ae8e2b004788e78.zip
Renamed (newish) functions expand_uninitialized to expand_uninit. + some minor changes.
Diffstat (limited to 'benchmarks/misc/prng_bench.cpp')
-rw-r--r--benchmarks/misc/prng_bench.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/benchmarks/misc/prng_bench.cpp b/benchmarks/misc/prng_bench.cpp
index e3524766..9d840316 100644
--- a/benchmarks/misc/prng_bench.cpp
+++ b/benchmarks/misc/prng_bench.cpp
@@ -41,6 +41,22 @@ static inline uint64_t sfc64(uint64_t s[4]) {
return result;
}
+uint32_t sfc32(uint32_t s[4]) {
+ uint32_t t = s[0] + s[1] + s[3]++;
+ s[0] = s[1] ^ (s[1] >> 9);
+ s[1] = s[2] + (s[2] << 3);
+ s[2] = (s[2] << 21) | (s[2] >> 11) + t;
+ return t;
+}
+
+uint32_t stc32(uint32_t s[5]) {
+ uint32_t t = (s[0] ^ (s[3] += s[4])) + s[1];
+ s[0] = s[1] ^ (s[1] >> 9);
+ s[1] = s[2] + (s[2] << 3);
+ s[2] = (s[2] << 21) | (s[2] >> 11) + t;
+ return t;
+}
+
/* xoshiro128+ */
uint64_t xoroshiro128plus(uint64_t s[2]) {
@@ -130,6 +146,22 @@ int main(void)
beg = clock();
for (size_t i = 0; i < N; i++)
+ recipient[i] = sfc32((uint32_t *)rng.state);
+ end = clock();
+ cout << "sfc32:\t\t"
+ << (float(end - beg) / CLOCKS_PER_SEC)
+ << "s: " << recipient[312] << endl;
+
+ beg = clock();
+ for (size_t i = 0; i < N; i++)
+ recipient[i] = stc32((uint32_t *)rng.state);
+ end = clock();
+ cout << "stc32:\t\t"
+ << (float(end - beg) / CLOCKS_PER_SEC)
+ << "s: " << recipient[312] << endl;
+
+ beg = clock();
+ for (size_t i = 0; i < N; i++)
recipient[i] = sfc64(rng.state);
end = clock();
cout << "sfc64:\t\t"
@@ -144,6 +176,7 @@ int main(void)
<< (float(end - beg) / CLOCKS_PER_SEC)
<< "s: " << recipient[312] << endl;
+
beg = clock();
for (size_t i = 0; i < N; i++)
recipient[i] = xoroshiro128plus(rng.state);