THRIFT-904: disable nagle and linger
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1063966 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/csharp/ThriftTest/TestClient.cs b/test/csharp/ThriftTest/TestClient.cs
index 1d7c75e..60fc995 100644
--- a/test/csharp/ThriftTest/TestClient.cs
+++ b/test/csharp/ThriftTest/TestClient.cs
@@ -39,7 +39,7 @@
int port = 9090;
string url = null;
int numThreads = 1;
- bool buffered = false;
+ bool buffered = false, framed = false;
try
{
@@ -67,6 +67,11 @@
buffered = true;
Console.WriteLine("Using buffered sockets");
}
+ else if (args[i] == "-f" || args[i] == "-framed")
+ {
+ framed = true;
+ Console.WriteLine("Using framed transport");
+ }
else if (args[i] == "-t")
{
numThreads = Convert.ToInt32(args[++i]);
@@ -89,16 +94,13 @@
threads[test] = t;
if (url == null)
{
- TSocket socket = new TSocket(host, port);
+ TTransport trans = new TSocket(host, port);
if (buffered)
- {
- TBufferedTransport buffer = new TBufferedTransport(socket);
- t.Start(buffer);
- }
- else
- {
- t.Start(socket);
- }
+ trans = new TBufferedTransport(trans as TStreamTransport);
+ if (framed)
+ trans = new TFramedTransport(trans);
+
+ t.Start(trans);
}
else
{
@@ -428,6 +430,12 @@
Console.WriteLine("Test Oneway(1)");
client.testOneway(1);
+
+ Console.Write("Test Calltime()");
+ var startt = DateTime.UtcNow;
+ for ( int k=0; k<1000; ++k )
+ client.testVoid();
+ Console.WriteLine(" = " + (DateTime.UtcNow - startt).TotalSeconds.ToString() + " ms a testVoid() call" );
}
}
}
diff --git a/test/csharp/ThriftTest/TestServer.cs b/test/csharp/ThriftTest/TestServer.cs
index e370640..894ec9c 100644
--- a/test/csharp/ThriftTest/TestServer.cs
+++ b/test/csharp/ThriftTest/TestServer.cs
@@ -301,7 +301,7 @@
{
try
{
- bool useBufferedSockets = false;
+ bool useBufferedSockets = false, useFramed = false;
int port = 9090;
if (args.Length > 0)
{
@@ -309,7 +309,23 @@
if (args.Length > 1)
{
- bool.TryParse(args[1], out useBufferedSockets);
+ if ( args[1] == "raw" )
+ {
+ // as default
+ }
+ else if ( args[1] == "buffered" )
+ {
+ useBufferedSockets = true;
+ }
+ else if ( args[1] == "framed" )
+ {
+ useFramed = true;
+ }
+ else
+ {
+ // Fall back to the older boolean syntax
+ bool.TryParse(args[1], out useBufferedSockets);
+ }
}
}
@@ -320,10 +336,12 @@
// Transport
TServerSocket tServerSocket = new TServerSocket(port, 0, useBufferedSockets);
- TServer serverEngine;
-
// Simple Server
- serverEngine = new TSimpleServer(testProcessor, tServerSocket);
+ TServer serverEngine;
+ if ( useFramed )
+ serverEngine = new TSimpleServer(testProcessor, tServerSocket, new TFramedTransport.Factory());
+ else
+ serverEngine = new TSimpleServer(testProcessor, tServerSocket);
// ThreadPool Server
// serverEngine = new TThreadPoolServer(testProcessor, tServerSocket);
@@ -334,7 +352,10 @@
testHandler.server = serverEngine;
// Run it
- Console.WriteLine("Starting the server on port " + port + (useBufferedSockets ? " with buffered socket" : "") + "...");
+ Console.WriteLine("Starting the server on port " + port +
+ (useBufferedSockets ? " with buffered socket" : "") +
+ (useFramed ? " with framed transport" : "") +
+ "...");
serverEngine.Serve();
}