提交 a0c38233 编写于 作者: T tanghai

增加Ping Pong测试,

1.使用TCP协议测试,10W次Rpc调用, windows平均耗时4S左右, linux下平均耗时5.6S
2.使用UDP协议测试,10W次Rpc调用, windows平均耗时4S左右, linux下平均耗时3S
上级 5a352844
using System;
using Model;
namespace Controller
{
[MessageHandler(AppType.Realm)]
public class C2R_PingHandler : AMRpcHandler<C2R_Ping, R2C_Ping>
{
protected override void Run(Session session, C2R_Ping message, Action<R2C_Ping> reply)
{
R2C_Ping r2CPing = new R2C_Ping();
reply(r2CPing);
}
}
}
\ No newline at end of file
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Message\C2G_LoginGateHandler.cs" /> <Compile Include="Message\C2G_LoginGateHandler.cs" />
<Compile Include="Message\C2R_PingHandler.cs" />
<Compile Include="Message\M2A_ReloadHandler.cs" /> <Compile Include="Message\M2A_ReloadHandler.cs" />
<Compile Include="Message\C2M_ReloadHandler.cs" /> <Compile Include="Message\C2M_ReloadHandler.cs" />
<Compile Include="Message\R2G_GetLoginKeyHandler.cs" /> <Compile Include="Message\R2G_GetLoginKeyHandler.cs" />
......
...@@ -17,12 +17,15 @@ namespace Model ...@@ -17,12 +17,15 @@ namespace Model
{ {
private int k; private int k;
public void Awake(string address) private long time1 = TimeHelper.ClientNowTicks();
public async void Awake(string address)
{ {
NetOuterComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>(); NetOuterComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
for (int i = 0; i < 400; i++) for (int i = 0; i < 100; i++)
{ {
await Game.Scene.GetComponent<TimerComponent>().WaitAsync(10);
TestAsync(networkComponent, address, i); TestAsync(networkComponent, address, i);
} }
} }
...@@ -32,22 +35,20 @@ namespace Model ...@@ -32,22 +35,20 @@ namespace Model
using (Session session = networkComponent.Create(address)) using (Session session = networkComponent.Create(address))
{ {
int i = 0; int i = 0;
while (i < 10000) while (i < 10000000)
{ {
++i; ++i;
try try
{ {
R2C_Login s2CLogin = await session.Call<C2R_Login, R2C_Login>(new C2R_Login { Account = "abcdef", Password = "111111" }); await session.Call<C2R_Ping, R2C_Ping>(new C2R_Ping());
using (Session gateSession = networkComponent.Create(s2CLogin.Address))
{
await gateSession.Call<C2G_LoginGate, G2C_LoginGate>(new C2G_LoginGate(s2CLogin.Key));
}
++this.k; ++this.k;
if (this.k % 1000 == 0) if (this.k % 100000 == 0)
{ {
Log.Info($"{j} Benchmark k: {k}"); long time2 = TimeHelper.ClientNowTicks();
long time = time2 - this.time1;
this.time1 = time2;
Log.Info($"{j} Benchmark k: {k} 每10W次耗时: {time}");
} }
} }
catch (RpcException e) catch (RpcException e)
......
...@@ -111,4 +111,16 @@ namespace Model ...@@ -111,4 +111,16 @@ namespace Model
public class A2M_Reload : AResponse public class A2M_Reload : AResponse
{ {
} }
[Message(14)]
[BsonIgnoreExtraElements]
public class C2R_Ping : ARequest
{
}
[Message(15)]
[BsonIgnoreExtraElements]
public class R2C_Ping : AResponse
{
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册