Generate all the benchmarks to run.
Instead of requiring the need to maintain a list of all the benchmarks,
add a programmatic way to generate all of the benchmarks.
This generation runs the benchmarks in alphabetical order.
Add a new macro BIONIC_BENCHMARK_WITH_ARG that will be the default argument
to pass to the benchmark. Change the benchmarks that require default arguments.
Add a small example xml file, and remove the full.xml/host.xml files.
Update readme.
Test: Ran new unit tests, verified all tests are added.
Change-Id: I8036daeae7635393222a7a92d18f34119adba745
diff --git a/benchmarks/util.h b/benchmarks/util.h
index cf6f50e..a546764 100644
--- a/benchmarks/util.h
+++ b/benchmarks/util.h
@@ -20,17 +20,18 @@
#include <map>
#include <mutex>
#include <string>
+#include <utility>
#include <vector>
typedef void (*benchmark_func_t) (void);
extern std::mutex g_map_lock;
-extern std::map<std::string, benchmark_func_t> g_str_to_func;
+extern std::map<std::string, std::pair<benchmark_func_t, std::string>> g_str_to_func;
-static int __attribute__((unused)) EmplaceBenchmark (std::string fn_name, benchmark_func_t fn_ptr) {
+static int __attribute__((unused)) EmplaceBenchmark (std::string fn_name, benchmark_func_t fn_ptr, std::string arg = "") {
g_map_lock.lock();
- g_str_to_func.emplace(std::string(fn_name), fn_ptr);
+ g_str_to_func.emplace(std::string(fn_name), std::make_pair(fn_ptr, arg));
g_map_lock.unlock();
return 0;
}
@@ -38,6 +39,10 @@
#define BIONIC_BENCHMARK(n) \
int _bionic_benchmark_##n __attribute__((unused)) = EmplaceBenchmark(std::string(#n), reinterpret_cast<benchmark_func_t>(n))
+#define BIONIC_BENCHMARK_WITH_ARG(n, arg) \
+ int _bionic_benchmark_##n __attribute__((unused)) = EmplaceBenchmark(std::string(#n), reinterpret_cast<benchmark_func_t>(n), arg)
+
+
constexpr auto KB = 1024;
typedef struct {