Browse Source

address review comments

Jan Tattermusch 5 years ago
parent
commit
447b6bbad8
2 changed files with 23 additions and 22 deletions
  1. 1 0
      Makefile.am
  2. 22 22
      csharp/src/Google.Protobuf.Benchmarks/ParseRawPrimitivesBenchmark.cs

+ 1 - 0
Makefile.am

@@ -88,6 +88,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs           \
   csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs           \
   csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs                        \
   csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs                        \
   csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj    \
   csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj    \
+  csharp/src/Google.Protobuf.Benchmarks/ParseRawPrimitivesBenchmark.cs       \
   csharp/src/Google.Protobuf.Benchmarks/Program.cs                           \
   csharp/src/Google.Protobuf.Benchmarks/Program.cs                           \
   csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs            \
   csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs            \
   csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs               \
   csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs               \

+ 22 - 22
csharp/src/Google.Protobuf.Benchmarks/ParseRawPrimitivesBenchmark.cs

@@ -45,7 +45,7 @@ namespace Google.Protobuf.Benchmarks
     public class ParseRawPrimitivesBenchmark
     public class ParseRawPrimitivesBenchmark
     {
     {
         // key is the encodedSize of varint values
         // key is the encodedSize of varint values
-        Dictionary<int, byte[]>  varintInputBuffers;
+        Dictionary<int, byte[]> varintInputBuffers;
 
 
         byte[] doubleInputBuffer;
         byte[] doubleInputBuffer;
         byte[] floatInputBuffer;
         byte[] floatInputBuffer;
@@ -87,13 +87,13 @@ namespace Google.Protobuf.Benchmarks
         [Arguments(5)]
         [Arguments(5)]
         public int ParseRawVarint32(int encodedSize)
         public int ParseRawVarint32(int encodedSize)
         {
         {
-             CodedInputStream cis = new CodedInputStream(varintInputBuffers[encodedSize]);
-             int sum = 0;
-             for (int i = 0; i < BytesToParse / encodedSize; i++)
-             {
-                 sum += cis.ReadInt32();
-             }
-             return sum;
+            CodedInputStream cis = new CodedInputStream(varintInputBuffers[encodedSize]);
+            int sum = 0;
+            for (int i = 0; i < BytesToParse / encodedSize; i++)
+            {
+                sum += cis.ReadInt32();
+            }
+            return sum;
         }
         }
 
 
         [Benchmark]
         [Benchmark]
@@ -109,13 +109,13 @@ namespace Google.Protobuf.Benchmarks
         [Arguments(10)]
         [Arguments(10)]
         public long ParseRawVarint64(int encodedSize)
         public long ParseRawVarint64(int encodedSize)
         {
         {
-             CodedInputStream cis = new CodedInputStream(varintInputBuffers[encodedSize]);
-             long sum = 0;
-             for (int i = 0; i < BytesToParse / encodedSize; i++)
-             {
-                 sum += cis.ReadInt64();
-             }
-             return sum;
+            CodedInputStream cis = new CodedInputStream(varintInputBuffers[encodedSize]);
+            long sum = 0;
+            for (int i = 0; i < BytesToParse / encodedSize; i++)
+            {
+                sum += cis.ReadInt64();
+            }
+            return sum;
         }
         }
 
 
         [Benchmark]
         [Benchmark]
@@ -161,13 +161,13 @@ namespace Google.Protobuf.Benchmarks
         public double ParseRawDouble()
         public double ParseRawDouble()
         {
         {
             const int encodedSize = sizeof(double);
             const int encodedSize = sizeof(double);
-             CodedInputStream cis = new CodedInputStream(doubleInputBuffer);
-             double sum = 0;
-             for (int i = 0; i < BytesToParse / encodedSize; i++)
-             {
-                 sum += cis.ReadDouble();
-             }
-             return sum;
+            CodedInputStream cis = new CodedInputStream(doubleInputBuffer);
+            double sum = 0;
+            for (int i = 0; i < BytesToParse / encodedSize; i++)
+            {
+                sum += cis.ReadDouble();
+            }
+            return sum;
         }
         }
 
 
         private static byte[] CreateBufferWithRandomVarints(Random random, int valueCount, int encodedSize, int paddingValueCount)
         private static byte[] CreateBufferWithRandomVarints(Random random, int valueCount, int encodedSize, int paddingValueCount)