summaryrefslogtreecommitdiffhomepage
path: root/benchmarks
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-11-23 08:38:45 +0100
committerTyge Løvset <[email protected]>2021-11-23 08:38:45 +0100
commitb24cf706b9bbaff0eb97d9663e43a1e5e065ab83 (patch)
tree576b69e63a001c24bea5d441125c31bb3b79ee26 /benchmarks
parent7d98bb163c9c1db7bf352f63deb8e186ac212676 (diff)
downloadSTC-modified-b24cf706b9bbaff0eb97d9663e43a1e5e065ab83.tar.gz
STC-modified-b24cf706b9bbaff0eb97d9663e43a1e5e065ab83.zip
Formatting only.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/misc/rust_cmap.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/benchmarks/misc/rust_cmap.c b/benchmarks/misc/rust_cmap.c
index d4a6f30c..aa96c2c5 100644
--- a/benchmarks/misc/rust_cmap.c
+++ b/benchmarks/misc/rust_cmap.c
@@ -6,29 +6,40 @@
#define i_tag u64
#include <stc/cmap.h>
-uint64_t romu_rotl(uint64_t val, uint32_t r)
- { return (val << r) | (val >> (64 - r)); }
+uint64_t romu_rotl(uint64_t val, uint32_t r) {
+ return (val << r) | (val >> (64 - r));
+}
uint64_t romu_trio(uint64_t s[3]) {
- const uint64_t xp = s[0], yp = s[1], zp = s[2];
+ const uint64_t xp = s[0],
+ yp = s[1],
+ zp = s[2];
s[0] = 15241094284759029579u * zp;
- s[1] = yp - xp; s[1] = romu_rotl(s[1], 12);
- s[2] = zp - yp; s[2] = romu_rotl(s[2], 44);
+ s[1] = yp - xp;
+ s[1] = romu_rotl(s[1], 12);
+ s[2] = zp - yp;
+ s[2] = romu_rotl(s[2], 44);
return xp;
}
-int main() {
+int main()
+{
c_auto (cmap_u64, m) {
- const size_t n = 50000000, mask = (1 << 25) - 1;
- cmap_u64_max_load_factor(&m, 0.8); cmap_u64_reserve(&m, n);
- uint64_t rng[3] = {1872361123, 123879177, 87739234}, sum, ms = CLOCKS_PER_SEC/1000;
+ const size_t n = 50000000,
+ mask = (1 << 25) - 1,
+ ms = CLOCKS_PER_SEC/1000;
+ cmap_u64_max_load_factor(&m, 0.8);
+ cmap_u64_reserve(&m, n);
printf("STC cmap n = %zu, mask = 0x%zx\n", n, mask);
+
+ uint64_t rng[3] = {1872361123, 123879177, 87739234}, sum;
clock_t now = clock();
c_forrange (n) {
uint64_t key = romu_trio(rng) & mask;
cmap_u64_insert(&m, key, 0).ref->second += 1;
}
printf("insert : %zums \tsize : %zu\n", (clock() - now)/ms, cmap_u64_size(m));
+
now = clock();
sum = 0;
c_forrange (key, mask + 1) { sum += cmap_u64_contains(&m, key); }