diff options
author | Haibo Huang <hhb@google.com> | 2018-07-06 15:55:25 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2018-07-07 04:14:22 +0000 |
commit | d5ee4c5fb70661f919cb8edf96212202c4c3f5f4 (patch) | |
tree | 6786a48ecb7e88965bfd3cef9f6bef9ac7292a60 /benchmarks | |
parent | 1d7c04c20ad640c41990cef1e04c99520b5a18eb (diff) | |
download | android_bionic-d5ee4c5fb70661f919cb8edf96212202c4c3f5f4.tar.gz android_bionic-d5ee4c5fb70661f919cb8edf96212202c4c3f5f4.tar.bz2 android_bionic-d5ee4c5fb70661f919cb8edf96212202c4c3f5f4.zip |
Change args to int64_t
The new benchmark framework uses int64_t for args.
Related benchmark change:
https://github.com/google/benchmark/commit/9913418d323e64a0111ca0da81388260c2bbe1e9#diff-b9f55422dc0bd52759c6aaa25c305bb0R757
Upgrade benchmark framework:
https://android-review.googlesource.com/c/platform/external/google-benchmark/+/714118
Test: compile and run bionic benchmark
Change-Id: I1b81c853c28abbead1816bf0be7a20a35e036619
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/bionic_benchmarks.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp index a5d7267a1..e4c32fa1f 100644 --- a/benchmarks/bionic_benchmarks.cpp +++ b/benchmarks/bionic_benchmarks.cpp @@ -16,6 +16,7 @@ #include <err.h> #include <getopt.h> +#include <inttypes.h> #include <math.h> #include <sys/resource.h> @@ -85,7 +86,7 @@ static struct option g_long_options[] = {0, 0, 0, 0}, }; -typedef std::vector<std::vector<int>> args_vector_t; +typedef std::vector<std::vector<int64_t>> args_vector_t; void Usage() { printf("Usage:\n"); @@ -212,15 +213,16 @@ void LockAndRun(benchmark::State& state, benchmark_func_t func_to_bench, int cpu static constexpr char kOnebufManualStr[] = "AT_ONEBUF_MANUAL_ALIGN_"; static constexpr char kTwobufManualStr[] = "AT_TWOBUF_MANUAL_ALIGN1_"; -static bool ParseOnebufManualStr(std::string& arg, std::vector<int>* values) { +static bool ParseOnebufManualStr(std::string& arg, std::vector<int64_t>* values) { // The format of this is: // AT_ONEBUF_MANUAL_ALIGN_XX_SIZE_YY // Where: // XX is the alignment // YY is the size - int align; - int size; - if (sscanf(arg.c_str(), "AT_ONEBUF_MANUAL_ALIGN_%d_SIZE_%d" , &align, &size) != 2) { + int64_t align; + int64_t size; + if (sscanf(arg.c_str(), "AT_ONEBUF_MANUAL_ALIGN_%" SCNd64 "_SIZE_%" SCNd64, + &align, &size) != 2) { return false; } @@ -228,22 +230,22 @@ static bool ParseOnebufManualStr(std::string& arg, std::vector<int>* values) { return false; } - values->push_back(static_cast<int>(size)); - values->push_back(static_cast<int>(align)); + values->push_back(static_cast<int64_t>(size)); + values->push_back(static_cast<int64_t>(align)); return true; } -static bool ParseTwobufManualStr(std::string& arg, std::vector<int>* values) { +static bool ParseTwobufManualStr(std::string& arg, std::vector<int64_t>* values) { // The format of this is: // AT_TWOBUF_MANUAL_ALIGN1_XX_ALIGN2_YY_SIZE_ZZ // Where: // XX is the alignment of the first argument // YY is the alignment of the second argument // ZZ is the size - int align1; - int align2; - int size; - if (sscanf(arg.c_str(), "AT_TWOBUF_MANUAL_ALIGN1_%d_ALIGN2_%d_SIZE_%d" , + int64_t align1; + int64_t align2; + int64_t size; + if (sscanf(arg.c_str(), "AT_TWOBUF_MANUAL_ALIGN1_%" SCNd64 "_ALIGN2_%" SCNd64 "_SIZE_%" SCNd64, &align1, &align2, &size) != 3) { return false; } @@ -254,9 +256,9 @@ static bool ParseTwobufManualStr(std::string& arg, std::vector<int>* values) { return false; } - values->push_back(static_cast<int>(size)); - values->push_back(static_cast<int>(align1)); - values->push_back(static_cast<int>(align2)); + values->push_back(static_cast<int64_t>(size)); + values->push_back(static_cast<int64_t>(align1)); + values->push_back(static_cast<int64_t>(align2)); return true; } @@ -270,7 +272,7 @@ args_vector_t* ResolveArgs(args_vector_t* to_populate, std::string args, } // Check for free form macro. if (android::base::StartsWith(args, kOnebufManualStr)) { - std::vector<int> values; + std::vector<int64_t> values; if (!ParseOnebufManualStr(args, &values)) { errx(1, "ERROR: Bad format of macro %s, should be AT_ONEBUF_MANUAL_ALIGN_XX_SIZE_YY", args.c_str()); @@ -278,7 +280,7 @@ args_vector_t* ResolveArgs(args_vector_t* to_populate, std::string args, to_populate->push_back(std::move(values)); return to_populate; } else if (android::base::StartsWith(args, kTwobufManualStr)) { - std::vector<int> values; + std::vector<int64_t> values; if (!ParseTwobufManualStr(args, &values)) { errx(1, "ERROR: Bad format of macro %s, should be AT_TWOBUF_MANUAL_ALIGN1_XX_ALIGNE2_YY_SIZE_ZZ", @@ -288,7 +290,7 @@ args_vector_t* ResolveArgs(args_vector_t* to_populate, std::string args, return to_populate; } - to_populate->push_back(std::vector<int>()); + to_populate->push_back(std::vector<int64_t>()); std::stringstream sstream(args); std::string argstr; while (sstream >> argstr) { @@ -318,7 +320,7 @@ void RegisterGoogleBenchmarks(bench_opts_t primary_opts, bench_opts_t secondary_ } benchmark_func_t benchmark_function = g_str_to_func.at(fn_name).first; - for (const std::vector<int>& args : (*run_args)) { + for (const std::vector<int64_t>& args : (*run_args)) { auto registration = benchmark::RegisterBenchmark(fn_name.c_str(), LockAndRun, benchmark_function, cpu_to_use)->Args(args); |