aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/generate_datasets.cc
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-04-29 10:19:03 -0700
committerJosh Haberman <jhaberman@gmail.com>2016-04-29 10:19:03 -0700
commit49a8918e9742d4bc9f577df9599061e342516b96 (patch)
treef0c409c0af621134bbaa0793c62624fd80f5dd2b /benchmarks/generate_datasets.cc
parentcb36bde04716436fc9560ac908ca4551bdc614fb (diff)
downloadprotobuf-49a8918e9742d4bc9f577df9599061e342516b96.tar.gz
protobuf-49a8918e9742d4bc9f577df9599061e342516b96.tar.bz2
protobuf-49a8918e9742d4bc9f577df9599061e342516b96.zip
Read files directly from filesystem since xxd isn't always available.
Diffstat (limited to 'benchmarks/generate_datasets.cc')
-rw-r--r--benchmarks/generate_datasets.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/benchmarks/generate_datasets.cc b/benchmarks/generate_datasets.cc
index f6f30cd8..8e9b441c 100644
--- a/benchmarks/generate_datasets.cc
+++ b/benchmarks/generate_datasets.cc
@@ -34,8 +34,6 @@ const char *file_suffix = ".pb";
#include <fstream>
#include <iostream>
#include "benchmarks.pb.h"
-#include "google_message1.h"
-#include "google_message2.h"
using benchmarks::BenchmarkDataset;
using google::protobuf::Descriptor;
@@ -102,13 +100,23 @@ void WriteFile(const std::string& name, const std::string& message_name,
WriteFileWithPayloads(name, message_name, payloads);
}
+std::string ReadFile(const std::string& name) {
+ std::ifstream file(name);
+ GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name <<
+ "', please make sure you are running "
+ "this command from the benchmarks/ "
+ "directory.\n";
+ return std::string((std::istreambuf_iterator<char>(file)),
+ std::istreambuf_iterator<char>());
+}
+
int main() {
WriteFile("google_message1_proto3", "benchmarks.p3.GoogleMessage1",
- ARRAY_TO_STRING(google_message1_dat));
+ ReadFile("google_message1.dat"));
WriteFile("google_message1_proto2", "benchmarks.p2.GoogleMessage1",
- ARRAY_TO_STRING(google_message1_dat));
+ ReadFile("google_message1.dat"));
// Not in proto3 because it has a group, which is not supported.
WriteFile("google_message2", "benchmarks.p2.GoogleMessage2",
- ARRAY_TO_STRING(google_message2_dat));
+ ReadFile("google_message2.dat"));
}