BenchmarkClientComponentSystem.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections.Generic;
  2. using System.Net.Sockets;
  3. using ET.Client;
  4. namespace ET.Server
  5. {
  6. [EntitySystemOf(typeof(BenchmarkClientComponent))]
  7. public static partial class BenchmarkClientComponentSystem
  8. {
  9. [EntitySystem]
  10. private static void Awake(this BenchmarkClientComponent self)
  11. {
  12. for (int i = 0; i < 10; ++i)
  13. {
  14. self.Start().Coroutine();
  15. }
  16. }
  17. private static async ETTask Start(this BenchmarkClientComponent self)
  18. {
  19. NetOuterComponent netOuterClientComponent = self.Root().GetComponent<NetOuterComponent>();
  20. using Session session = netOuterClientComponent.Create(StartSceneConfigCategory.Instance.Benchmark.OuterIPPort);
  21. List<ETTask> list = new List<ETTask>(100000);
  22. async ETTask Call(Session s)
  23. {
  24. using G2C_Benchmark benchmark = await s.Call(C2G_Benchmark.Create()) as G2C_Benchmark;
  25. }
  26. for (int j = 0; j < 100000000; ++j)
  27. {
  28. list.Clear();
  29. for (int i = 0; i < list.Capacity; ++i)
  30. {
  31. list.Add(Call(session));
  32. }
  33. await ETTaskHelper.WaitAll(list);
  34. }
  35. }
  36. }
  37. }