Josh Haberman 9 лет назад
Родитель
Сommit
247ef1f0df

+ 1 - 1
benchmarks/benchmark_messages_proto2.proto

@@ -2,7 +2,7 @@
 
 syntax = "proto2";
 
-package benchmarks.p2;
+package benchmarks.proto2;
 option java_package = "com.google.protobuf.benchmarks";
 
 // This is the default, but we specify it here explicitly.

+ 1 - 1
benchmarks/benchmark_messages_proto3.proto

@@ -2,7 +2,7 @@
 
 syntax = "proto3";
 
-package benchmarks.p3;
+package benchmarks.proto3;
 option java_package = "com.google.protobuf.benchmarks";
 
 // This is the default, but we specify it here explicitly.

+ 0 - 41
benchmarks/benchmarks.proto

@@ -61,44 +61,3 @@ message BenchmarkDataset {
   // good branch prediction performance.
   repeated bytes payload = 3;
 }
-
-// A benchmark can write out metrics that we will then upload to our metrics
-// database for tracking over time.
-message Metric {
-  // A unique ID for these results.  Used for de-duping.
-  string guid = 1;
-
-  // The labels specify exactly what benchmark was run against the dataset.
-  // The specific benchmark suite can decide what these mean, but here are
-  // some common labels that have a predefined meaning:
-  //
-  //   - "dataset": for tests that pertain to a specific dataset.
-  //
-  // For example:
-  //
-  //   # Tests parsing from binary proto string using arenas.
-  //   labels={
-  //     dataset: "testalltypes",
-  //     op: "parse",
-  //     format: "binaryproto",
-  //     input: "string"
-  //     arena: "true"
-  //   }
-  //
-  //   # Tests serializing to JSON string.
-  //   labels={
-  //     dataset: "testalltypes",
-  //     op: "serialize",
-  //     format: "json",
-  //     input: "string"
-  //   }
-  map<string, string> labels = 2;
-
-  // Unit of measurement for the metric:
-  //  - a speed test might be "mb_per_second" or "ops_per_second"
-  //  - a size test might be "kb".
-  string unit = 3;
-
-  // Metric value.
-  double value = 4;
-}

+ 7 - 12
benchmarks/generate_datasets.cc

@@ -28,9 +28,6 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-const char *file_prefix = "dataset.";
-const char *file_suffix = ".pb";
-
 #include <fstream>
 #include <iostream>
 #include "benchmarks.pb.h"
@@ -41,10 +38,11 @@ using google::protobuf::DescriptorPool;
 using google::protobuf::Message;
 using google::protobuf::MessageFactory;
 
-#define ARRAY_TO_STRING(arr) std::string(arr, arr + sizeof(arr))
-
 std::set<std::string> names;
 
+const char *file_prefix = "dataset.";
+const char *file_suffix = ".pb";
+
 void WriteFileWithPayloads(const std::string& name,
                            const std::string& message_name,
                            const std::vector<std::string>& payload) {
@@ -81,13 +79,10 @@ void WriteFileWithPayloads(const std::string& name,
     dataset.add_payload()->assign(payload[i]);
   }
 
-  std::string serialized;
-  dataset.SerializeToString(&serialized);
-
   std::ofstream writer;
   std::string fname = file_prefix + name + file_suffix;
   writer.open(fname.c_str());
-  writer << serialized;
+  dataset.SerializeToOstream(&writer);
   writer.close();
 
   std::cerr << "Wrote dataset: " << fname << "\n";
@@ -111,12 +106,12 @@ std::string ReadFile(const std::string& name) {
 }
 
 int main() {
-  WriteFile("google_message1_proto3", "benchmarks.p3.GoogleMessage1",
+  WriteFile("google_message1_proto3", "benchmarks.proto3.GoogleMessage1",
             ReadFile("google_message1.dat"));
-  WriteFile("google_message1_proto2", "benchmarks.p2.GoogleMessage1",
+  WriteFile("google_message1_proto2", "benchmarks.proto2.GoogleMessage1",
             ReadFile("google_message1.dat"));
 
   // Not in proto3 because it has a group, which is not supported.
-  WriteFile("google_message2", "benchmarks.p2.GoogleMessage2",
+  WriteFile("google_message2", "benchmarks.proto2.GoogleMessage2",
             ReadFile("google_message2.dat"));
 }