Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: third_party/grpc/src/csharp/Grpc.Core.Tests/PerformanceTest.cs

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/src/csharp/Grpc.Core.Tests/PerformanceTest.cs
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs b/third_party/grpc/src/csharp/Grpc.Core.Tests/PerformanceTest.cs
similarity index 51%
copy from third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs
copy to third_party/grpc/src/csharp/Grpc.Core.Tests/PerformanceTest.cs
index e8a6073e2bcb6b6f47dafb1f67f31de9b4a8671a..68158399921ccc05df412eb27708050082be5ef6 100644
--- a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs
+++ b/third_party/grpc/src/csharp/Grpc.Core.Tests/PerformanceTest.cs
@@ -1,7 +1,7 @@
#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+
+// Copyright 2015, Google Inc.
+// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,45 +28,72 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
#endregion
using System;
-using System.IO;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using Grpc.Core.Profiling;
+using Grpc.Core.Utils;
+using NUnit.Framework;
-namespace Google.Protobuf.ProtoDump
+namespace Grpc.Core.Tests
{
- /// <summary>
- /// Small utility to load a binary message and dump it in JSON format.
- /// </summary>
- internal class Program
+ public class PerformanceTest
{
- private static int Main(string[] args)
+ const string Host = "127.0.0.1";
+
+ MockServiceHelper helper;
+ Server server;
+ Channel channel;
+
+ [SetUp]
+ public void Init()
{
- if (args.Length != 2)
- {
- Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump <descriptor type name> <input data>");
- Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,");
- Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project");
- return 1;
- }
- Type type = Type.GetType(args[0]);
- if (type == null)
+ helper = new MockServiceHelper(Host);
+ server = helper.GetServer();
+ server.Start();
+ channel = helper.GetChannel();
+ }
+
+ [TearDown]
+ public void Cleanup()
+ {
+ channel.ShutdownAsync().Wait();
+ server.ShutdownAsync().Wait();
+ }
+
+ [Test]
+ [Category("Performance")]
+ [Ignore("Prevent running on Jenkins")]
+ public void UnaryCallPerformance()
+ {
+ var profiler = new BasicProfiler();
+ Profilers.SetForCurrentThread(profiler);
+
+ helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
{
- Console.Error.WriteLine("Unable to load type {0}.", args[0]);
- return 1;
- }
- if (!typeof(IMessage).IsAssignableFrom(type))
+ return request;
+ });
+
+ var callDetails = helper.CreateUnaryCall();
+ for(int i = 0; i < 3000; i++)
{
- Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
- return 1;
+ Calls.BlockingUnaryCall(callDetails, "ABC");
}
- IMessage message = (IMessage) Activator.CreateInstance(type);
- using (var input = File.OpenRead(args[1]))
+
+ profiler.Reset();
+
+ for(int i = 0; i < 3000; i++)
{
- message.MergeFrom(input);
+ Calls.BlockingUnaryCall(callDetails, "ABC");
}
- Console.WriteLine(message);
- return 0;
+ profiler.Dump("latency_trace_csharp.txt");
}
}
-}
+}

Powered by Google App Engine
This is Rietveld 408576698