summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-09-11 22:15:43 +0200
committerTyge Løvset <[email protected]>2021-09-11 22:15:43 +0200
commit658019e1e53ad1ccbca5c623b7199c445eab8b86 (patch)
tree609f3f69e0058984f7b30b06ad2e6cfb9736fb27
parentaba4aad980ff7f171f53c34915da0755f0ed079c (diff)
downloadSTC-modified-658019e1e53ad1ccbca5c623b7199c445eab8b86.tar.gz
STC-modified-658019e1e53ad1ccbca5c623b7199c445eab8b86.zip
Updated benchmarks to newstyle.
-rw-r--r--benchmarks/cdeq_benchmark.cpp5
-rw-r--r--benchmarks/clist_benchmark.cpp5
-rw-r--r--benchmarks/cmap_benchmark.cpp7
-rw-r--r--benchmarks/cpque_benchmark.cpp8
-rw-r--r--benchmarks/csmap_benchmark.cpp6
-rw-r--r--benchmarks/cvec_benchmark.cpp5
-rw-r--r--benchmarks/shootout1_cmap.cpp18
-rw-r--r--benchmarks/shootout2_cmap.cpp8
-rw-r--r--benchmarks/shootout3_csmap.cpp17
-rw-r--r--examples/csset_erase.c18
-rw-r--r--include/stc/cdeq.h4
11 files changed, 69 insertions, 32 deletions
diff --git a/benchmarks/cdeq_benchmark.cpp b/benchmarks/cdeq_benchmark.cpp
index 15e03ff0..a12dddf0 100644
--- a/benchmarks/cdeq_benchmark.cpp
+++ b/benchmarks/cdeq_benchmark.cpp
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/cdeq.h>
#ifdef __cplusplus
#include <deque>
@@ -17,7 +16,9 @@ uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
-using_cdeq(x, size_t);
+#define i_tag x
+#define i_val size_t
+#include <stc/cdeq.h>
#ifdef __cplusplus
Sample test_std_deque() {
diff --git a/benchmarks/clist_benchmark.cpp b/benchmarks/clist_benchmark.cpp
index 3ed91e6c..7c1f164e 100644
--- a/benchmarks/clist_benchmark.cpp
+++ b/benchmarks/clist_benchmark.cpp
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/clist.h>
#ifdef __cplusplus
#include <forward_list>
@@ -17,7 +16,9 @@ uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
-using_clist(x, size_t);
+#define i_tag x
+#define i_val size_t
+#include <stc/clist.h>
#ifdef __cplusplus
Sample test_std_forward_list() {
diff --git a/benchmarks/cmap_benchmark.cpp b/benchmarks/cmap_benchmark.cpp
index 3fb939fa..98f90479 100644
--- a/benchmarks/cmap_benchmark.cpp
+++ b/benchmarks/cmap_benchmark.cpp
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/cmap.h>
#ifdef __cplusplus
#include <unordered_map>
@@ -16,7 +15,11 @@ uint64_t seed = 1, mask1 = 0xffffffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
-using_cmap(x, size_t, size_t, c_default_equals, c_default_hash64);
+#define i_tag x
+#define i_key size_t
+#define i_val size_t
+#define i_hash c_default_hash64
+#include <stc/cmap.h>
#ifdef __cplusplus
Sample test_std_unordered_map() {
diff --git a/benchmarks/cpque_benchmark.cpp b/benchmarks/cpque_benchmark.cpp
index c8d327ff..2b6445c5 100644
--- a/benchmarks/cpque_benchmark.cpp
+++ b/benchmarks/cpque_benchmark.cpp
@@ -1,11 +1,11 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/cvec.h>
-#include <stc/cpque.h>
-using_cvec(f, float);
-using_cpque(f, cvec_f, -c_default_compare);
+#define i_tag x
+#define i_val float
+#define i_cmp -c_default_compare
+#include <stc/cpque.h>
int main()
{
diff --git a/benchmarks/csmap_benchmark.cpp b/benchmarks/csmap_benchmark.cpp
index 0c73ca32..cd7f5509 100644
--- a/benchmarks/csmap_benchmark.cpp
+++ b/benchmarks/csmap_benchmark.cpp
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/csmap.h>
#ifdef __cplusplus
#include <map>
@@ -16,7 +15,10 @@ uint64_t seed = 1, mask1 = 0xfffffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
-using_csmap(x, size_t, size_t);
+#define i_tag x
+#define i_key size_t
+#define i_val size_t
+#include <stc/csmap.h>
#ifdef __cplusplus
Sample test_std_map() {
diff --git a/benchmarks/cvec_benchmark.cpp b/benchmarks/cvec_benchmark.cpp
index f85a02a4..755659a7 100644
--- a/benchmarks/cvec_benchmark.cpp
+++ b/benchmarks/cvec_benchmark.cpp
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <stc/crandom.h>
-#include <stc/cvec.h>
#ifdef __cplusplus
#include <vector>
@@ -17,7 +16,9 @@ uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
-using_cvec(x, size_t);
+#define i_tag x
+#define i_val size_t
+#include <stc/cvec.h>
#ifdef __cplusplus
Sample test_std_vector() {
diff --git a/benchmarks/shootout1_cmap.cpp b/benchmarks/shootout1_cmap.cpp
index d368afa8..5fd32586 100644
--- a/benchmarks/shootout1_cmap.cpp
+++ b/benchmarks/shootout1_cmap.cpp
@@ -1,6 +1,5 @@
#include <stc/crandom.h>
#include <stc/cstr.h>
-#include <stc/cmap.h>
#include <cmath>
#include <string>
#include <unordered_map>
@@ -39,10 +38,21 @@ DEFMAP(map_i, <int, int>);
DEFMAP(map_x, <uint64_t, uint64_t>);
DEFMAP(map_s, <std::string, std::string>);
-using_cmap(i, int, int, c_default_equals, c_default_hash32);
-using_cmap(x, uint64_t, uint64_t, c_default_equals, c_default_hash64);
-using_cmap_str();
+#define i_tag i
+#define i_key int
+#define i_val int
+#define i_hash c_default_hash32
+#include <stc/cmap.h>
+#define i_tag x
+#define i_key size_t
+#define i_val size_t
+#define i_hash c_default_hash64
+#include <stc/cmap.h>
+
+#define i_key_str
+#define i_val_str
+#include <stc/cmap.h>
PICOBENCH_SUITE("Map1");
diff --git a/benchmarks/shootout2_cmap.cpp b/benchmarks/shootout2_cmap.cpp
index 7c1595f3..669c336c 100644
--- a/benchmarks/shootout2_cmap.cpp
+++ b/benchmarks/shootout2_cmap.cpp
@@ -2,7 +2,6 @@
#include <time.h>
#include <stc/crandom.h>
#include <stc/cstr.h>
-#include <stc/cmap.h>
#include "others/khash.h"
#ifdef __cplusplus
@@ -18,7 +17,12 @@ template<typename C> inline void destroy_me(C& c) { C().swap(c); }
// Visual Studio: compile with -TP to force C++: cl -TP -EHsc -O2 benchmark.c
// cmap and khash template expansion
-using_cmap(ii, int64_t, int64_t, c_default_equals, c_default_hash64); // c_default_hash);
+#define i_tag ii
+#define i_key int64_t
+#define i_val int64_t
+#define i_cmp c_default_hash64
+#include <stc/cmap.h>
+
KHASH_MAP_INIT_INT64(ii, int64_t)
diff --git a/benchmarks/shootout3_csmap.cpp b/benchmarks/shootout3_csmap.cpp
index de14d4ba..6f124cd8 100644
--- a/benchmarks/shootout3_csmap.cpp
+++ b/benchmarks/shootout3_csmap.cpp
@@ -1,7 +1,6 @@
#include <iostream>
#include <stc/crandom.h>
#include <stc/cstr.h>
-#include <stc/csmap.h>
#include <cmath>
#include <string>
#include <map>
@@ -16,9 +15,19 @@ using omap_i = std::map<int, int>;
using omap_x = std::map<uint64_t, uint64_t>;
using omap_s = std::map<std::string, std::string>;
-using_csmap(i, int, int);
-using_csmap(x, uint64_t, uint64_t);
-using_csmap_str();
+#define i_tag i
+#define i_key int
+#define i_val int
+#include <stc/csmap.h>
+
+#define i_tag x
+#define i_key size_t
+#define i_val size_t
+#include <stc/csmap.h>
+
+#define i_key_str
+#define i_val_str
+#include <stc/csmap.h>
PICOBENCH_SUITE("Map1");
diff --git a/examples/csset_erase.c b/examples/csset_erase.c
index 774201b2..a8b2c9d0 100644
--- a/examples/csset_erase.c
+++ b/examples/csset_erase.c
@@ -7,24 +7,30 @@ int main()
{
c_forauto (csset_int, set)
{
- c_var (csset_int, set, {30, 20, 80, 40, 60, 90, 10, 70, 50});
- c_foreach (k, csset_int, set) printf(" %d", *k.ref); puts("");
+ c_emplace(csset_int, set, {30, 20, 80, 40, 60, 90, 10, 70, 50});
+ c_foreach (k, csset_int, set)
+ printf(" %d", *k.ref);
+ puts("");
int val = 64;
csset_int_iter_t it;
printf("Show values >= %d:\n", val);
it = csset_int_lower_bound(&set, val);
- c_foreach (k, csset_int, it, csset_int_end(&set)) printf(" %d", *k.ref); puts("");
+ c_foreach (k, csset_int, it, csset_int_end(&set))
+ printf(" %d", *k.ref); puts("");
printf("Erase values >= %d:\n", val);
while (it.ref) it = csset_int_erase_at(&set, it);
- c_foreach (k, csset_int, set) printf(" %d", *k.ref); puts("");
+ c_foreach (k, csset_int, set)
+ printf(" %d", *k.ref);
+ puts("");
val = 40;
printf("Erase values < %d:\n", val);
it = csset_int_lower_bound(&set, val);
csset_int_erase_range(&set, csset_int_begin(&set), it);
- c_foreach (k, csset_int, set) printf(" %d", *k.ref); puts("");
+ c_foreach (k, csset_int, set)
+ printf(" %d", *k.ref);
+ puts("");
}
}
-
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 7658b7a6..c6993427 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -234,7 +234,7 @@ cx_memb(_realloc_)(Self* self, size_t n) {
size_t sz = rep->size, cap = (size_t) (sz*1.7) + n + 7;
size_t nfront = _cdeq_nfront(self);
rep = (struct cdeq_rep*) c_realloc(rep->cap ? rep : NULL,
- offsetof(struct cdeq_rep, base) + cap*sizeof(i_val));
+ offsetof(struct cdeq_rep, base) + cap*sizeof(i_val));
rep->size = sz, rep->cap = cap;
self->_base = (cx_value_t *) rep->base;
self->data = self->_base + nfront;
@@ -257,7 +257,7 @@ cx_memb(_expand_right_half_)(Self* self, size_t idx, size_t n) {
#endif
memmove(self->_base + pos, self->data, idx*sizeof(i_val));
memmove(self->data + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
- self->data = ((cx_value_t *) self->_base) + pos;
+ self->data = self->_base + pos;
}
}