diff options
author | Yilun Chong <chongyilun250@sina.com> | 2017-12-05 10:54:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-05 10:54:14 -0800 |
commit | 173f3043d30317c16caa6a5c1e16db2540e8170c (patch) | |
tree | a6f8121ac2fab8ee99f27b6155ae222732bbffaa /benchmarks/cpp_benchmark.cc | |
parent | db7c043f6dce400e4c777810a76fe900a7f0bc7e (diff) | |
parent | 1fd6c1761e7c70081af3b71a76a890002d4b578d (diff) | |
download | protobuf-173f3043d30317c16caa6a5c1e16db2540e8170c.tar.gz protobuf-173f3043d30317c16caa6a5c1e16db2540e8170c.tar.bz2 protobuf-173f3043d30317c16caa6a5c1e16db2540e8170c.zip |
Merge pull request #3926 from BSBandme/down_sync_benchmark
Sync benchmark changes from internal
Diffstat (limited to 'benchmarks/cpp_benchmark.cc')
-rw-r--r-- | benchmarks/cpp_benchmark.cc | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/benchmarks/cpp_benchmark.cc b/benchmarks/cpp_benchmark.cc index 0e6febc2..e26c8d11 100644 --- a/benchmarks/cpp_benchmark.cc +++ b/benchmarks/cpp_benchmark.cc @@ -28,13 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <glob.h> -#include <iostream> #include <fstream> +#include <iostream> #include "benchmark/benchmark_api.h" #include "benchmarks.pb.h" -#include "benchmark_messages_proto2.pb.h" -#include "benchmark_messages_proto3.pb.h" +#include "datasets/google_message1/benchmark_message1_proto2.pb.h" +#include "datasets/google_message1/benchmark_message1_proto3.pb.h" +#include "datasets/google_message2/benchmark_message2.pb.h" +#include "datasets/google_message3/benchmark_message3.pb.h" +#include "datasets/google_message4/benchmark_message4.pb.h" + #define PREFIX "dataset." #define SUFFIX ".pb" @@ -219,6 +222,14 @@ void RegisterBenchmarks(const std::string& dataset_bytes) { RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage1>(dataset); } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") { RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage2>(dataset); + } else if (dataset.message_name() == + "benchmarks.google_message3.GoogleMessage3") { + RegisterBenchmarksForType + <benchmarks::google_message3::GoogleMessage3>(dataset); + } else if (dataset.message_name() == + "benchmarks.google_message4.GoogleMessage4") { + RegisterBenchmarksForType + <benchmarks::google_message4::GoogleMessage4>(dataset); } else { std::cerr << "Unknown message type: " << dataset.message_name(); exit(1); @@ -226,15 +237,15 @@ void RegisterBenchmarks(const std::string& dataset_bytes) { } int main(int argc, char *argv[]) { - glob_t glob_result; - if (glob("dataset.*.pb", 0, NULL, &glob_result) != 0) { - fprintf(stderr, "No dataset files found.\n"); + if (argc == 1) { + std::cerr << "Usage: ./cpp-benchmark <input data>" << std::endl; + std::cerr << "input data is in the format of \"benchmarks.proto\"" + << std::endl; return 1; - } - - for (size_t i = 0; i < glob_result.gl_pathc; i++) { - fprintf(stderr, "Found input dataset: %s\n", glob_result.gl_pathv[i]); - RegisterBenchmarks(ReadFile(glob_result.gl_pathv[i])); + } else { + for (int i = 1; i < argc; i++) { + RegisterBenchmarks(ReadFile(argv[i])); + } } ::benchmark::Initialize(&argc, argv); |