diff --git a/plugins.vcxproj.filters b/plugins.vcxproj.filters
new file mode 100644
index 00000000000..5ce08010501
--- /dev/null
+++ b/plugins.vcxproj.filters
@@ -0,0 +1,17 @@
+
+
+
+
+ CMake Rules
+
+
+
+
+
+
+
+
+ {870DBD13-69C5-3F27-A253-623E8947E2E7}
+
+
+
diff --git a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs
index e19010f0509..af264c9be5d 100644
--- a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs
+++ b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs
@@ -27,9 +27,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-
-[assembly: InternalsVisibleTo("Grpc.Microbenchmarks,PublicKey=" +
- "00240000048000009400000006020000002400005253413100040000010001002f5797a92c6fcde81bd4098f43" +
- "0442bb8e12768722de0b0cb1b15e955b32a11352740ee59f2c94c48edc8e177d1052536b8ac651bce11ce5da3a" +
- "27fc95aff3dc604a6971417453f9483c7b5e836756d5b271bf8f2403fe186e31956148c03d804487cf642f8cc0" +
- "71394ee9672dfe5b55ea0f95dfd5a7f77d22c962ccf51320d3")]
diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
index 89597e139ec..f775e4c85fb 100644
--- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
+++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
@@ -11,7 +11,6 @@
-
diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs
index cbb4091122b..4061a1a0f02 100644
--- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs
+++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
-using System.Text;
using BenchmarkDotNet.Attributes;
using Grpc.Core;
using Grpc.Core.Internal;
-using Grpc.Core.Internal.Tests;
namespace Grpc.Microbenchmarks
{
@@ -12,9 +10,7 @@ namespace Grpc.Microbenchmarks
[MemoryDiagnoser] // allocations
public class Utf8Encode : ISendStatusFromServerCompletionCallback
{
- static readonly NativeMethods Native = NativeMethods.Get();
-
- [Params(0, 1, 4, 128, 1024)]
+ [Params(0)] //, 1, 4, 128, 1024)]
public int PayloadSize { get; set; }
static readonly Dictionary Payloads = new Dictionary {
@@ -36,22 +32,50 @@ namespace Grpc.Microbenchmarks
return new string(chars);
}
+ private GrpcEnvironment environment;
+
[GlobalSetup]
public void Setup()
{
- Native.grpcsharp_test_override_method("grpcsharp_call_start_batch", "nop");
+ var native = NativeMethods.Get();
+
+ // ??? throws ???
+ native.grpcsharp_test_override_method(nameof(NativeMethods.grpcsharp_call_send_status_from_server), "nop");
+
+ environment = GrpcEnvironment.AddRef();
metadata = MetadataArraySafeHandle.Create(Metadata.Empty);
- call = new FakeNativeCall();
+ var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException());
+ var cq = CompletionQueueSafeHandle.CreateAsync(completionRegistry);
+ call = CreateFakeCall(cq);
+ }
+
+ private static CallSafeHandle CreateFakeCall(CompletionQueueSafeHandle cq)
+ {
+ var call = CallSafeHandle.CreateFake(new IntPtr(0xdead), cq);
+ bool success = false;
+ while (!success)
+ {
+ // avoid calling destroy on a nonexistent grpc_call pointer
+ call.DangerousAddRef(ref success);
+ }
+ return call;
}
+ [GlobalCleanup]
public void Cleanup()
{
- metadata.Dispose();
+ metadata?.Dispose();
metadata = null;
- call.Dispose();
+ call?.Dispose();
call = null;
+
+ if (environment != null)
+ {
+ environment = null;
+ GrpcEnvironment.ReleaseAsync().Wait();
+ }
}
- private INativeCall call;
+ private CallSafeHandle call;
private MetadataArraySafeHandle metadata;
const int Iterations = 1000;
@@ -62,8 +86,7 @@ namespace Grpc.Microbenchmarks
var status = new Status(StatusCode.OK, payload);
for (int i = 0; i < Iterations; i++)
{
- call.StartSendStatusFromServer(this, status,
- metadata, false, null, WriteFlags.NoCompress);
+ call.StartSendStatusFromServer(this, status, metadata, false, null, WriteFlags.NoCompress);
}
}