summaryrefslogtreecommitdiffhomepage
path: root/misc/benchmarks/various/rust_cmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/benchmarks/various/rust_cmap.c')
-rw-r--r--misc/benchmarks/various/rust_cmap.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/misc/benchmarks/various/rust_cmap.c b/misc/benchmarks/various/rust_cmap.c
index 83b7dd19..abdb42b0 100644
--- a/misc/benchmarks/various/rust_cmap.c
+++ b/misc/benchmarks/various/rust_cmap.c
@@ -24,38 +24,40 @@ uint64_t romu_trio(uint64_t s[3]) {
int main()
{
- c_auto (cmap_u64, m) {
- const size_t n = 50000000,
- mask = (1 << 25) - 1,
- ms = CLOCKS_PER_SEC/1000;
- cmap_u64_reserve(&m, n);
- printf("STC cmap n = %" c_ZU ", mask = 0x%" PRIxMAX "\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 : %" c_ZU "ms \tsize : %" c_ZU "\n", (clock() - now)/ms, cmap_u64_size(&m));
-
- now = clock();
- sum = 0;
- c_forrange (key, mask + 1) { sum += cmap_u64_contains(&m, key); }
- printf("lookup : %" c_ZU "ms \tsum : %" c_ZU "\n", (clock() - now)/ms, sum);
-
- now = clock();
- sum = 0;
- c_foreach (i, cmap_u64, m) { sum += i.ref->second; }
- printf("iterate : %" c_ZU "ms \tsum : %" c_ZU "\n", (clock() - now)/ms, sum);
-
- uint64_t rng2[3] = {1872361123, 123879177, 87739234};
- now = clock();
- c_forrange (n) {
- uint64_t key = romu_trio(rng2) & mask;
- cmap_u64_erase(&m, key);
- }
- printf("remove : %" c_ZU "ms \tsize : %" c_ZU "\n", (clock() - now)/ms, cmap_u64_size(&m));
- printf("press a key:\n"); getchar();
+ cmap_u64 m = {0};
+
+ const size_t n = 50000000,
+ mask = (1 << 25) - 1,
+ ms = CLOCKS_PER_SEC/1000;
+ cmap_u64_reserve(&m, n);
+ printf("STC cmap n = %" c_ZU ", mask = 0x%" PRIxMAX "\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 : %" c_ZU "ms \tsize : %" c_ZU "\n", (clock() - now)/ms, cmap_u64_size(&m));
+
+ now = clock();
+ sum = 0;
+ c_forrange (key, mask + 1) { sum += cmap_u64_contains(&m, key); }
+ printf("lookup : %" c_ZU "ms \tsum : %" c_ZU "\n", (clock() - now)/ms, sum);
+
+ now = clock();
+ sum = 0;
+ c_foreach (i, cmap_u64, m) { sum += i.ref->second; }
+ printf("iterate : %" c_ZU "ms \tsum : %" c_ZU "\n", (clock() - now)/ms, sum);
+
+ uint64_t rng2[3] = {1872361123, 123879177, 87739234};
+ now = clock();
+ c_forrange (n) {
+ uint64_t key = romu_trio(rng2) & mask;
+ cmap_u64_erase(&m, key);
+ }
+ printf("remove : %" c_ZU "ms \tsize : %" c_ZU "\n", (clock() - now)/ms, cmap_u64_size(&m));
+ printf("press a key:\n"); getchar();
+
+ cmap_u64_drop(&m);
}