diff options
| author | Tyge Løvset <[email protected]> | 2022-09-26 08:08:47 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-26 08:08:47 +0200 |
| commit | ca01dd726e2ed8f8b69f8ff08855e80f4eea7247 (patch) | |
| tree | 0ce1594c39d18a93212f066fd8c3c2477fc6f22b /benchmarks/plotbench/clist_benchmark.cpp | |
| parent | ad5be4349232bbba96c0974bc2693ec7331c4b12 (diff) | |
| download | STC-modified-ca01dd726e2ed8f8b69f8ff08855e80f4eea7247.tar.gz STC-modified-ca01dd726e2ed8f8b69f8ff08855e80f4eea7247.zip | |
DEPRECATED: c_forrange(): replaced with c_forloop(). This uses 'long long' as iter type, i.e. "%lld" printf format.
crange_from() renamed to crange_make().
More docs.
Diffstat (limited to 'benchmarks/plotbench/clist_benchmark.cpp')
| -rw-r--r-- | benchmarks/plotbench/clist_benchmark.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/benchmarks/plotbench/clist_benchmark.cpp b/benchmarks/plotbench/clist_benchmark.cpp index ddd1e2f0..c18ee78e 100644 --- a/benchmarks/plotbench/clist_benchmark.cpp +++ b/benchmarks/plotbench/clist_benchmark.cpp @@ -29,28 +29,28 @@ Sample test_std_forward_list() { s.test[INSERT].t1 = clock(); container con; csrandom(seed); - c_forrange (N/2) con.push_front(crandom() & mask1); - c_forrange (N/2) con.push_front(crandom() & mask1); + c_forloop (N/2) con.push_front(crandom() & mask1); + c_forloop (N/2) con.push_front(crandom() & mask1); s.test[INSERT].t2 = clock(); s.test[INSERT].sum = 0; s.test[ERASE].t1 = clock(); - c_forrange (N) con.pop_front(); + c_forloop (N) con.pop_front(); s.test[ERASE].t2 = clock(); s.test[ERASE].sum = 0; }{ container con; csrandom(seed); - c_forrange (N) con.push_front(crandom() & mask2); + c_forloop (N) con.push_front(crandom() & 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(), crandom() & mask2)) != con.end()) sum += *it; + //c_forloop (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it; s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); sum = 0; - c_forrange (R) for (auto i: con) sum += i; + c_forloop (R) for (auto i: con) sum += i; s.test[ITER].t2 = clock(); s.test[ITER].sum = sum; s.test[DESTRUCT].t1 = clock(); @@ -71,28 +71,28 @@ Sample test_stc_forward_list() { s.test[INSERT].t1 = clock(); container con = clist_x_init(); csrandom(seed); - c_forrange (N/2) clist_x_push_front(&con, crandom() & mask1); - c_forrange (N/2) clist_x_push_back(&con, crandom() & mask1); + c_forloop (N/2) clist_x_push_front(&con, crandom() & mask1); + c_forloop (N/2) clist_x_push_back(&con, crandom() & mask1); s.test[INSERT].t2 = clock(); s.test[INSERT].sum = 0; s.test[ERASE].t1 = clock(); - c_forrange (N) clist_x_pop_front(&con); + c_forloop (N) clist_x_pop_front(&con); s.test[ERASE].t2 = clock(); s.test[ERASE].sum = 0; clist_x_drop(&con); }{ csrandom(seed); container con = clist_x_init(); - c_forrange (N) clist_x_push_front(&con, crandom() & mask2); + c_forloop (N) clist_x_push_front(&con, crandom() & mask2); s.test[FIND].t1 = clock(); size_t sum = 0; //clist_x_iter it, end = clist_x_end(&con); - //c_forrange (S) if ((it = clist_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref; + //c_forloop (S) if ((it = clist_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref; s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); sum = 0; - c_forrange (R) c_foreach (i, clist_x, con) sum += *i.ref; + c_forloop (R) c_foreach (i, clist_x, con) sum += *i.ref; s.test[ITER].t2 = clock(); s.test[ITER].sum = sum; s.test[DESTRUCT].t1 = clock(); @@ -106,30 +106,30 @@ Sample test_stc_forward_list() { int main(int argc, char* argv[]) { Sample std_s[SAMPLES + 1], stc_s[SAMPLES + 1]; - c_forrange (i, int, SAMPLES) { + c_forloop (i, SAMPLES) { std_s[i] = test_std_forward_list(); stc_s[i] = test_stc_forward_list(); - if (i > 0) c_forrange (j, int, N_TESTS) { + if (i > 0) c_forloop (j, N_TESTS) { if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j]; if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j]; - if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %d, sample %d\n", i, j); + if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\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) { + c_forloop (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); } if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n"); - c_forrange (j, N_TESTS) + c_forloop (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) + c_forloop (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 |
