diff options
| author | Tyge Løvset <[email protected]> | 2021-02-11 19:12:45 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-02-11 19:12:45 +0100 |
| commit | e6ea4740c9fad4a9453fb62432ef238d2761271c (patch) | |
| tree | 9ed659c2857c99a6b8d25bbdf34523868a112c33 | |
| parent | debbd4efac5cea9b71468d36f7f11ab9b25837b9 (diff) | |
| download | STC-modified-e6ea4740c9fad4a9453fb62432ef238d2761271c.tar.gz STC-modified-e6ea4740c9fad4a9453fb62432ef238d2761271c.zip | |
Updated benchmarks
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | benchmarks/cdeq_benchmark.cpp | 45 | ||||
| -rw-r--r-- | benchmarks/clist_benchmark.cpp | 39 | ||||
| -rw-r--r-- | benchmarks/cmap_benchmark.cpp | 18 | ||||
| -rw-r--r-- | benchmarks/csmap_benchmark.cpp | 13 | ||||
| -rw-r--r-- | benchmarks/cvec_benchmark.cpp | 39 | ||||
| -rw-r--r-- | benchmarks/plot.py | 9 |
7 files changed, 112 insertions, 59 deletions
@@ -198,6 +198,8 @@ The containers are memory efficent, i.e. they occupy as little memory as practic FAQ
---
-- Why is **cmap** so fast?
-- How come **cvec_str_emplace_back()** can take a `const char *` argument, when its value type **cstr** cannot be directly assigned with a `const char *`?
-- more ...
+- **Q**: Why is **cmap** so fast?
+- **A**: Many reasons. It uses open addressing which holds all buckets in one block of memory. It uses a separate array for precomputed hashes/used buckets - only one byte per bucket. It avoids modulus operations and erases elements without leaving tombstones. Modern architechtures favors simple code and cached memory access, so linear probing is actually as fast or faster than the more advanced Robin Hood and Hopscotch hashing schemes, and they require tombstones. **cmap** does not rely on wasteful power-of-two array sizes, it actually expands only by 1.5x when required.
+
+- **Q**: How come **cvec_str_emplace_back()** can take a `const char *` argument, when its value type `cstr` cannot be directly assigned from a `const char *`?
+- **A**: STC containers simulates automatic type convertion found in c++. All containers can take an optional "rawvalue" type as template parameter in the **using_**-declaration, along with back and forth convertion methods to the container value type. By default, rawvalue is equal to value. Various **emplace()**, **cmap_put()** and lookup methods accepts the rawvalue type, which is convenient e.g. for strings. But also map insertions, because values are only conditionally inserted to maps. The **emplace()** method construct the cstr object from a rawvalue only when needed. **using_cvec_str()** declares `cvec_str` container type with predefined `cstr` value and `const char *` rawvalue, along with convertion methods.
diff --git a/benchmarks/cdeq_benchmark.cpp b/benchmarks/cdeq_benchmark.cpp index ff1c9361..52e829ff 100644 --- a/benchmarks/cdeq_benchmark.cpp +++ b/benchmarks/cdeq_benchmark.cpp @@ -5,15 +5,15 @@ #ifdef __cplusplus
#include <deque>
+#include <algorithm>
#endif
enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 3, N = 100000000};
-
-uint64_t seed = 1, mask1 = 0xfffffff;
+enum {SAMPLES = 2, N = 100000000, S = 0x3ffc};
+uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
@@ -39,9 +39,16 @@ Sample test_std_deque() { }{
container con;
stc64_srandom(seed);
- c_forrange (N) con.push_back(stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) con.push_back(stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ container::iterator it;
+ // Iteration - not inherent find - skipping
+ //c_forrange (S) if ((it = std::find(con.begin(), con.end(), stc64_random() & mask2)) != con.end()) sum += *it;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
c_forrange (i, N) sum += con[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -64,9 +71,9 @@ Sample test_stc_deque() { container con = cdeq_x_init();
//cdeq_x_reserve(&con, N);
stc64_srandom(seed);
- c_forrange (N/2) cdeq_x_push_front(&con, stc64_random() & mask1);
- c_forrange (N/2) { cdeq_x_push_back(&con, stc64_random() & mask1); cdeq_x_pop_front(&con); }
- c_forrange (N/2) cdeq_x_push_back(&con, stc64_random() & mask1);
+ c_forrange (N/3) cdeq_x_push_front(&con, stc64_random() & mask1);
+ c_forrange (N/3) { cdeq_x_push_back(&con, stc64_random() & mask1); cdeq_x_pop_front(&con); }
+ c_forrange (N/3) cdeq_x_push_back(&con, stc64_random() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = cdeq_x_size(con);
s.test[ERASE].t1 = clock();
@@ -77,9 +84,15 @@ Sample test_stc_deque() { }{
stc64_srandom(seed);
container con = cdeq_x_init();
- c_forrange (N) cdeq_x_push_back(&con, stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) cdeq_x_push_back(&con, stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ cdeq_x_iter_t it;
+ //c_forrange (S) if ((it = cdeq_x_find(&con, stc64_random() & mask2)).ref) sum += *it.ref;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
c_forrange (i, N) sum += *cdeq_x_at(&con, i);
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -103,11 +116,13 @@ int main(int argc, char* argv[]) if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j);
}
}
+ const char* comp = argc > 1 ? argv[1] : "test";
+ bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); }
- if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n");
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
+ if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/benchmarks/clist_benchmark.cpp b/benchmarks/clist_benchmark.cpp index f8cadae3..543cf099 100644 --- a/benchmarks/clist_benchmark.cpp +++ b/benchmarks/clist_benchmark.cpp @@ -5,15 +5,15 @@ #ifdef __cplusplus
#include <forward_list>
+#include <algorithm>
#endif
enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 3, N = 50000000};
-
-uint64_t seed = 1, mask1 = 0xfffffff;
+enum {SAMPLES = 2, N = 50000000, S = 0x3ffc};
+uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
@@ -38,9 +38,16 @@ Sample test_std_forward_list() { }{
container con;
stc64_srandom(seed);
- c_forrange (N) con.push_front(stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) con.push_front(stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ container::iterator it;
+ // Iteration - not inherent find - skipping
+ //c_forrange (S) if ((it = std::find(con.begin(), con.end(), stc64_random() & mask2)) != con.end()) sum += *it;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
for (auto i: con) sum += i;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -74,9 +81,15 @@ Sample test_stc_forward_list() { }{
stc64_srandom(seed);
container con = clist_x_init();
- c_forrange (N) clist_x_push_front(&con, stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) clist_x_push_front(&con, stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ clist_x_iter_t it;
+ //c_forrange (S) if ((it = clist_x_find(&con, stc64_random() & mask2)).ref) sum += *it.ref;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
c_foreach (i, clist_x, con) sum += *i.ref;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -100,11 +113,13 @@ int main(int argc, char* argv[]) if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j);
}
}
+ const char* comp = argc > 1 ? argv[1] : "test";
+ bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); }
- if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n");
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
+ if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
\ No newline at end of file diff --git a/benchmarks/cmap_benchmark.cpp b/benchmarks/cmap_benchmark.cpp index fe1cd2e9..d9cb1722 100644 --- a/benchmarks/cmap_benchmark.cpp +++ b/benchmarks/cmap_benchmark.cpp @@ -16,7 +16,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_hash32);
+static inline uint32_t hash64(const void* data, size_t len) {
+ uint64_t x = *(const uint64_t *)data * 11400714819323198485ull;
+ return x ^ (x >> 32);
+}
+using_cmap(x, size_t, size_t, c_default_equals, hash64);
#ifdef __cplusplus
Sample test_std_unordered_map() {
@@ -117,11 +121,13 @@ int main(int argc, char* argv[]) if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j);
}
}
+ const char* comp = argc > 1 ? argv[1] : "test";
+ bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); }
- if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n");
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
+ if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
\ No newline at end of file diff --git a/benchmarks/csmap_benchmark.cpp b/benchmarks/csmap_benchmark.cpp index d0214fd2..ec64d94c 100644 --- a/benchmarks/csmap_benchmark.cpp +++ b/benchmarks/csmap_benchmark.cpp @@ -12,7 +12,6 @@ const char* operations[] = {"insert", "erase", "find", "iter", "destruct"}; typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
enum {SAMPLES = 2, N = 4000000};
-
uint64_t seed = 1, mask1 = 0xfffffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
@@ -119,11 +118,13 @@ int main(int argc, char* argv[]) if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j);
}
}
+ const char* comp = argc > 1 ? argv[1] : "test";
+ bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); }
- if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n");
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
+ if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/benchmarks/cvec_benchmark.cpp b/benchmarks/cvec_benchmark.cpp index e7a4c869..c208b3a2 100644 --- a/benchmarks/cvec_benchmark.cpp +++ b/benchmarks/cvec_benchmark.cpp @@ -5,15 +5,15 @@ #ifdef __cplusplus
#include <vector>
+#include <algorithm>
#endif
enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 3, N = 150000000};
-
-uint64_t seed = 1, mask1 = 0xfffffff;
+enum {SAMPLES = 2, N = 150000000, S = 0x3ffc};
+uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
@@ -37,9 +37,16 @@ Sample test_std_vector() { }{
container con;
stc64_srandom(seed);
- c_forrange (N) con.push_back(stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) con.push_back(stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ container::iterator it;
+ // Iteration - not inherent find - skipping
+ //c_forrange (S) if ((it = std::find(con.begin(), con.end(), stc64_random() & mask2)) != con.end()) sum += *it;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
c_forrange (i, N) sum += con[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -73,9 +80,15 @@ Sample test_stc_vector() { }{
stc64_srandom(seed);
container con = cvec_x_init();
- c_forrange (N) cvec_x_push_back(&con, stc64_random() & mask1);
- s.test[ITER].t1 = clock();
+ c_forrange (N) cvec_x_push_back(&con, stc64_random() & mask2);
+ s.test[FIND].t1 = clock();
size_t sum = 0;
+ cvec_x_iter_t it;
+ //c_forrange (S) if ((it = cvec_x_find(&con, stc64_random() & mask2)).ref) sum += *it.ref;
+ s.test[FIND].t2 = clock();
+ s.test[FIND].sum = sum;
+ s.test[ITER].t1 = clock();
+ sum = 0;
c_forrange (i, N) sum += *cvec_x_at(&con, i);
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
@@ -99,11 +112,13 @@ int main(int argc, char* argv[]) if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j);
}
}
+ const char* comp = argc > 1 ? argv[1] : "test";
+ bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); }
- if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n");
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
- printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
+ if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
+ c_forrange (j, N_TESTS) printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
+ printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/benchmarks/plot.py b/benchmarks/plot.py index 382aedfe..228209e2 100644 --- a/benchmarks/plot.py +++ b/benchmarks/plot.py @@ -15,19 +15,18 @@ df = pd.read_csv('all.csv') #df['sum'] = df[column_list].sum(axis=1)
#df = df.sort_values('sum', ascending=False)
-# Plot the total crashes
#sns.set_color_codes("pastel")
-#g1 = sns.barplot(x='operation', y='ratio', data=df, hue='Library', ci=68)
+#g1 = sns.barplot(x='Method', y='Ratio', data=df, hue='Library', ci=68)
-df = df[df.operation != 'total']
-g = sns.catplot(data=df, x='operation', y='time', hue='Library', col='C', kind='bar',
+df = df[df.Method != 'total']
+g = sns.catplot(data=df, x='Method', y='Seconds', hue='Library', col='C', kind='bar',
ci=68, legend=False, col_wrap=2, sharex=False, aspect=1.6, height=3)
g.set_xlabels('')
g.add_legend(bbox_to_anchor=(0.75, 0.2), borderaxespad=0.)
g.fig.subplots_adjust(top=0.90, left=0.06, bottom=0.07)
-g.fig.suptitle('Benchmarks STC vs c++ std containers', fontsize=15, y=0.98)
+g.fig.suptitle('Benchmark STC vs c++ std containers', fontsize=15, y=0.98)
#a1 = g.fig.axes[1]
#a1.set_title("Custom Title")
|
