C# benchmarks: honor optimizationtarget channel arg

pull/13418/head
Jan Tattermusch 7 years ago
parent 57a66242d0
commit ea6cc57f1e
  1. 15
      src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
  2. 43
      src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs
  3. 3
      src/csharp/Grpc.IntegrationTesting/ServerRunners.cs

@ -72,7 +72,7 @@ namespace Grpc.IntegrationTesting
Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value");
}
var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams);
var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams, config.ChannelArgs);
return new ClientRunnerImpl(channels,
config.ClientType,
@ -84,19 +84,20 @@ namespace Grpc.IntegrationTesting
() => GetNextProfiler());
}
private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams)
private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams, IEnumerable<ChannelArg> channelArguments)
{
GrpcPreconditions.CheckArgument(clientChannels > 0, "clientChannels needs to be at least 1.");
GrpcPreconditions.CheckArgument(serverTargets.Count() > 0, "at least one serverTarget needs to be specified.");
var credentials = securityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure;
List<ChannelOption> channelOptions = null;
var channelOptions = new List<ChannelOption>();
if (securityParams != null && securityParams.ServerHostOverride != "")
{
channelOptions = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride)
};
channelOptions.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride));
}
foreach (var channelArgument in channelArguments)
{
channelOptions.Add(channelArgument.ToChannelOption());
}
var result = new List<Channel>();

@ -0,0 +1,43 @@
#region Copyright notice and license
// Copyright 2016 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
using System;
using Grpc.Core;
using Grpc.Testing;
namespace Grpc.IntegrationTesting
{
/// <summary>
/// Helpers for Control.cs
/// </summary>
public static class ControlExtensions
{
public static ChannelOption ToChannelOption(this ChannelArg channelArgument)
{
switch (channelArgument.ValueCase)
{
case ChannelArg.ValueOneofCase.StrValue:
return new ChannelOption(channelArgument.Name, channelArgument.StrValue);
case ChannelArg.ValueOneofCase.IntValue:
return new ChannelOption(channelArgument.Name, channelArgument.IntValue);
default:
throw new ArgumentException("Unsupported channel argument value.");
}
}
}
}

@ -78,7 +78,8 @@ namespace Grpc.IntegrationTesting
throw new ArgumentException("Unsupported ServerType");
}
var server = new Server
var channelOptions = new List<ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption()));
var server = new Server(channelOptions)
{
Services = { service },
Ports = { new ServerPort("[::]", config.Port, credentials) }

Loading…
Cancel
Save