aboutsummaryrefslogtreecommitdiff
path: root/microbench/microbench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'microbench/microbench.cpp')
-rw-r--r--microbench/microbench.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/microbench/microbench.cpp b/microbench/microbench.cpp
new file mode 100644
index 0000000..0d21e5f
--- /dev/null
+++ b/microbench/microbench.cpp
@@ -0,0 +1,41 @@
+
+#include "api.h"
+
+#include <vector>
+#include <boost/timer/timer.hpp>
+#include <iostream>
+
+int main(int, char*[]) {
+ struct Api api = get_implementation();
+
+ size_t nr_test = 10000;
+
+ std::vector<GroupElement> elements(nr_test);
+
+ boost::timer::cpu_timer timer;
+ timer.start();
+
+ for(auto&& el : elements) {
+ el = api.get_group_element(true);
+ }
+
+ auto random_time = timer.elapsed().user;
+
+ for(size_t i = 0; i < nr_test; i++) {
+ elements[i] = api.combine(elements[i], elements[(i+1) % nr_test], true);
+ }
+
+ auto combine_time = timer.elapsed().user - random_time;
+
+ for(size_t i = 0; i < nr_test; i++) {
+ elements[i] = api.uncombine(elements[i], elements[(i+1) % nr_test], true);
+ }
+
+ auto uncombine_time = timer.elapsed().user - combine_time;
+ timer.stop();
+
+ std::cout << "Micro Benchmark:" << std::endl
+ << "Random:\t\t" << random_time / 1000000.0 << " ms" << std::endl
+ << "Combine:\t" << combine_time / 1000000.0 << " ms" << std::endl
+ << "Uncombine:\t" << uncombine_time / 1000000.0 << " ms" << std::endl;
+}