summaryrefslogtreecommitdiffhomepage
path: root/benchmarks
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-11-03 13:28:45 +0100
committerTyge Løvset <[email protected]>2022-11-03 13:28:45 +0100
commitd1d8a9f389155c223db92d060b8fbccda58e2e53 (patch)
tree718fac6edbf34056c188fadfec63f9c15514a32c /benchmarks
parenta913e030b5db2e0d0a49234a86fa39930b4ed6e9 (diff)
downloadSTC-modified-d1d8a9f389155c223db92d060b8fbccda58e2e53.tar.gz
STC-modified-d1d8a9f389155c223db92d060b8fbccda58e2e53.zip
Made cmap i_max_load_factor a compile time template parameter instead of runtime. Enables cmap to be NULL initialized. Currently only cvec/cdeq and csmap cannot be NULL initialized, but eventually they will.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/misc/rust_cmap.c2
-rw-r--r--benchmarks/picobench/picobench_cmap.cpp8
-rw-r--r--benchmarks/shootout_hashmaps.cpp4
3 files changed, 6 insertions, 8 deletions
diff --git a/benchmarks/misc/rust_cmap.c b/benchmarks/misc/rust_cmap.c
index 0750b182..83b7dd19 100644
--- a/benchmarks/misc/rust_cmap.c
+++ b/benchmarks/misc/rust_cmap.c
@@ -3,6 +3,7 @@
#define i_key uint64_t
#define i_val uint64_t
#define i_tag u64
+#define i_max_load_factor 0.8f
#include <stc/cmap.h>
uint64_t romu_rotl(uint64_t val, uint32_t r) {
@@ -27,7 +28,6 @@ int main()
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 = %" c_ZU ", mask = 0x%" PRIxMAX "\n", n, mask);
diff --git a/benchmarks/picobench/picobench_cmap.cpp b/benchmarks/picobench/picobench_cmap.cpp
index 7d114d30..3ffba5b9 100644
--- a/benchmarks/picobench/picobench_cmap.cpp
+++ b/benchmarks/picobench/picobench_cmap.cpp
@@ -33,15 +33,18 @@ DEFMAP(map_s, <std::string, std::string>);
#define i_key int32_t
#define i_val int32_t
#define i_tag i
+#define i_max_load_factor float(MaxLoadFactor100) / 100.0f
#include <stc/cmap.h>
#define i_key uint64_t
#define i_val uint64_t
#define i_tag x
+#define i_max_load_factor float(MaxLoadFactor100) / 100.0f
#include <stc/cmap.h>
#define i_key_str
#define i_val_str
+#define i_max_load_factor float(MaxLoadFactor100) / 100.0f
#include <stc/cmap.h>
PICOBENCH_SUITE("Map1");
@@ -69,7 +72,6 @@ static void ins_and_erase_i(picobench::state& s)
static void ins_and_erase_cmap_i(picobench::state& s)
{
cmap_i map = cmap_i_init();
- cmap_i_max_load_factor(&map, (int)MaxLoadFactor100 / 100.0);
csrandom(seed);
picobench::scope scope(s);
@@ -89,7 +91,6 @@ static void ins_and_erase_cmap_i(picobench::state& s)
static void ins_and_erase_cmap_x(picobench::state& s)
{
cmap_x map = cmap_x_init();
- cmap_x_max_load_factor(&map, (int)MaxLoadFactor100 / 100.0);
csrandom(seed);
picobench::scope scope(s);
@@ -136,7 +137,6 @@ static void ins_and_access_cmap_i(picobench::state& s)
uint64_t mask = (1ull << s.arg()) - 1;
size_t result = 0;
cmap_i map = cmap_i_init();
- cmap_i_max_load_factor(&map, (int)MaxLoadFactor100 / 100.0);
csrandom(seed);
picobench::scope scope(s);
@@ -189,7 +189,6 @@ static void ins_and_access_cmap_s(picobench::state& s)
char* buf = cstr_data(&str);
size_t result = 0;
cmap_str map = cmap_str_init();
- cmap_str_max_load_factor(&map, (int)MaxLoadFactor100 / 100.0);
csrandom(seed);
picobench::scope scope(s);
@@ -249,7 +248,6 @@ static void iterate_x(picobench::state& s)
static void iterate_cmap_x(picobench::state& s)
{
cmap_x map = cmap_x_init();
- cmap_x_max_load_factor(&map, (int)MaxLoadFactor100 / 100.0);
uint64_t K = (1ull << s.arg()) - 1;
picobench::scope scope(s);
diff --git a/benchmarks/shootout_hashmaps.cpp b/benchmarks/shootout_hashmaps.cpp
index d662ed60..d29149e2 100644
--- a/benchmarks/shootout_hashmaps.cpp
+++ b/benchmarks/shootout_hashmaps.cpp
@@ -36,13 +36,13 @@ KHASH_MAP_INIT_INT64(ii, IValue)
#define i_val IValue
#define i_size uint32_t // optional, enables 2x expand
#define i_tag ii
+#define i_max_load_factor MAX_LOAD_FACTOR / 100.0f
#include <stc/cmap.h>
#define SEED(s) rng = stc64_new(s)
#define RAND(N) (stc64_rand(&rng) & (((uint64_t)1 << N) - 1))
-#define CMAP_SETUP(X, Key, Value) cmap_##X map = cmap_##X##_init(); \
- cmap_##X##_max_load_factor(&map, MAX_LOAD_FACTOR/100.0f)
+#define CMAP_SETUP(X, Key, Value) cmap_##X map = cmap_##X##_init()
#define CMAP_PUT(X, key, val) cmap_##X##_insert_or_assign(&map, key, val).ref->second
#define CMAP_EMPLACE(X, key, val) cmap_##X##_insert(&map, key, val).ref->second
#define CMAP_ERASE(X, key) cmap_##X##_erase(&map, key)