lith 4 lat temu
rodzic
commit
946460326d

+ 4 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiNode_Original.cs

@@ -1,6 +1,8 @@
 using Newtonsoft.Json;
 using Sers.Core.Module.Api.ApiDesc;
 using System;
+using System.Runtime.CompilerServices;
+
 using Vit.Extensions;
 
 namespace Sers.Core.Module.Api.LocalApi
@@ -37,7 +39,8 @@ namespace Sers.Core.Module.Api.LocalApi
 
 
 
-        public  byte[] Invoke(ArraySegment<byte> arg_OriData)
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public byte[] Invoke(ArraySegment<byte> arg_OriData)
         {        
             return onInvoke(arg_OriData);
         }

+ 5 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Rpc/Extensions/ECallerSourceExtensions.cs

@@ -1,4 +1,6 @@
-using Sers.Core.Module.Rpc;
+using System.Runtime.CompilerServices;
+
+using Sers.Core.Module.Rpc;
 
 namespace Vit.Extensions
 {
@@ -8,6 +10,7 @@ namespace Vit.Extensions
     public static partial class ECallerSourceExtensions
     {
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static string EnumToString(this ECallerSource data)
         {
             //return data.ToString(); 相对比较慢
@@ -20,6 +23,7 @@ namespace Vit.Extensions
         }
 
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static ECallerSource ToECallerSource(this string data)
         {
             switch (data)

+ 23 - 11
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Rpc/Extensions/RpcContextDataExtensions.cs

@@ -2,6 +2,7 @@
 using Sers.Core.Module.Rpc;
 using Vit.Core.Util.Common;
 using System.IO;
+using System.Runtime.CompilerServices;
 
 namespace Vit.Extensions
 {
@@ -15,18 +16,20 @@ namespace Vit.Extensions
 
         #region Init
 
-        public static RpcContextData Init(this RpcContextData rpcData, String callerSource=nameof(ECallerSource.Internal))
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public static RpcContextData Init(this RpcContextData rpcData, String callerSource = nameof(ECallerSource.Internal))
         {
             var rid = CommonHelp.NewGuid();
-             
+
             rpcData.caller.rid = rid;
-            rpcData.caller.source = callerSource; 
+            rpcData.caller.source = callerSource;
 
             return rpcData;
         }
 
- 
 
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static RpcContextData Init(this RpcContextData data, string url, string httpMethod = null)
         {
             data.http.url = "http://sers.internal" + url;
@@ -39,18 +42,18 @@ namespace Vit.Extensions
 
                 // b2?a=c
                 if (queryIndex >= 0)
-{
+                {
                     data.route = url.Substring(0, queryIndex);
                 }
                 else
-{
+                {
                     data.route = url;
                 }
             }
             #endregion              
 
             //(x.3)设置httpMethod
-            if (httpMethod != null) data.http.method=httpMethod;
+            if (httpMethod != null) data.http.method = httpMethod;
 
             return data;
         }
@@ -59,6 +62,7 @@ namespace Vit.Extensions
 
         #region InitFromRpcContext
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static RpcContextData InitFromRpcContext(this RpcContextData rpcData)
         {
             rpcData.Init();
@@ -80,7 +84,7 @@ namespace Vit.Extensions
             //rpcData.http=rpcDataFromContext.http;
 
             //(x.4) user
-            rpcData.user = rpcDataFromContext.user;    
+            rpcData.user = rpcDataFromContext.user;
 
 
             return rpcData;
@@ -97,6 +101,7 @@ namespace Vit.Extensions
         /// </summary>
         /// <param name="data"></param>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static String http_url_search_Get(this RpcContextData data)
         {
             // "http://127.0.0.1/Station1/fold1/a/1/2.html?c=9"
@@ -120,6 +125,7 @@ namespace Vit.Extensions
         /// <para>(若 route为"/Station1/fold1/a/*",url为"http://127.0.0.1/Station1/fold1/a/1/2.html?c=9",则 relativePath为"1/2.html")</para>
         /// </summary>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static string http_url_RelativeUrl_Get(this RpcContextData rpcData)
         {
             // "1/2.html?c=9"
@@ -144,6 +150,7 @@ namespace Vit.Extensions
         /// <para>(若 route为"/Station1/fold1/a/*",url为"http://127.0.0.1/Station1/fold1/a/1/2.html?c=9",则 relativePath为"1\\2.html")</para>
         /// </summary>
         /// <returns></returns>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static string http_url_RelativePath_Get(this RpcContextData rpcData)
         {
             String relativePath = http_url_RelativeUrl_Get(rpcData);
@@ -155,14 +162,16 @@ namespace Vit.Extensions
 
 
         #region Content-Type
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static String http_header_ContentType_Get(this RpcContextData data)
         {
             return data.http.GetHeader("Content-Type");
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static RpcContextData http_header_ContentType_Set(this RpcContextData data, String value)
         {
-             data.http.headers["Content-Type"]=value;
+            data.http.headers["Content-Type"] = value;
             return data;
         }
         #endregion
@@ -170,6 +179,7 @@ namespace Vit.Extensions
 
 
         #region apiStationName_Get
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static string apiStationName_Get(this RpcContextData data)
         {
             var arr = data.route?.Split('/');
@@ -179,14 +189,16 @@ namespace Vit.Extensions
         #endregion
 
         #region caller_callStack
-       
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static String caller_parentRid_Get(this RpcContextData data)
         {
-            var ja = data.caller.callStack ;
+            var ja = data.caller.callStack;
             if (null == ja || ja.Count == 0) return null;
             return ja[ja.Count - 1];
         }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static String caller_rootRid_Get(this RpcContextData data)
         {
             var ja = data.caller.callStack;

+ 3 - 0
dotnet/Library/Sers/Sers.Core/Test/Sers.Core.Module.LocalApi.Qps/LocalApi/Controllers/DemoController.cs

@@ -1,5 +1,7 @@
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.CompilerServices;
+
 using Sers.SersLoader;
 using Vit.Core.Util.ComponentModel.Api;
 
@@ -14,6 +16,7 @@ namespace Sers.Core.Module.LocalApi.MsTest.LocalApi.Controllers
             public string name { get; set; }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         [SsRoute("/a")]
         public void A()
         {    

+ 3 - 2
dotnet/Library/Sers/Sers.Core/Test/Sers.Core.Module.LocalApi.Qps/LocalApi/LocalApiTest.cs

@@ -36,7 +36,8 @@ namespace Sers.Core.Module.LocalApi.MsTest.LocalApi
 
             Action<string> callApi = null;
 
-            callApi = reply =>{
+            callApi = reply =>
+            {
 
                 t++;
                 if (t >= 1000)
@@ -44,7 +45,7 @@ namespace Sers.Core.Module.LocalApi.MsTest.LocalApi
                     t = 0;
                     qpsInfo.RequestCount++;
                 }
-                
+
                 //string route = "/Test/api/GetDeviceGuidList";
                 //string arg = "asfsdf";
                 //object argValue = new { arg };

+ 4 - 4
dotnet/Library/Sers/Sers.Core/Test/Sers.Core.Module.LocalApi.Qps/Program.cs

@@ -16,19 +16,19 @@ namespace DeliveryTest
         {
             try
             {
-                int requestTreadCount = 16;
+                
                 LocalApiTest.workThreadCount = 16;
-
+                int requestTreadCount = 32;
                 if (args != null)
                 {
                     if (args.Length >=1)
                     {
-                        int.TryParse(args[0], out requestTreadCount);
+                        int.TryParse(args[0], out LocalApiTest.workThreadCount);
                     }
 
                     if (args.Length >= 2)
                     {
-                        int.TryParse(args[1], out LocalApiTest.workThreadCount);
+                        int.TryParse(args[1], out requestTreadCount);
                     }
                 }
                 for (var t = 0; t < requestTreadCount; t++)

+ 1 - 1
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Dynamic/DynamicMethodExecutor.cs

@@ -7,7 +7,7 @@ using System.Runtime.CompilerServices;
 namespace Vit.Core.Util.Dynamic
 {
     /// <summary>
-    ///  
+    ///  参考 https://blog.csdn.net/chuifuhuo6864/article/details/100879510
     /// </summary>
     public class DynamicMethodExecutor
     {

+ 4 - 2
dotnet/ServiceStation/ApiLoader/Sers.NetcoreLoader/LocalApiNode.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Reflection;
+using System.Runtime.CompilerServices;
 using System.Threading.Tasks;
 using Microsoft.AspNetCore.Mvc;
 using Newtonsoft.Json;
@@ -154,10 +155,11 @@ namespace Sers.NetcoreLoader
             #endregion
         }
 
-        
 
 
-        public /*virtual*/ byte[] Invoke(ArraySegment<byte> arg_OriData)
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public byte[] Invoke(ArraySegment<byte> arg_OriData)
         {
             //(x.1)反序列化 请求参数
             //var args = apiDesc.argType?.Deserialize(arg_OriData);

+ 2 - 0
dotnet/ServiceStation/ApiLoader/Sers.Serslot/Extensions/SerslotServer_ProcessRequest_Extensions.cs

@@ -4,11 +4,13 @@ using System;
 using System.IO;
 using Microsoft.AspNetCore.Http;
 using Sers.Serslot;
+using System.Runtime.CompilerServices;
 
 namespace Vit.Extensions
 {
     public static partial class SerslotServer_ProcessRequest_Extensions
     {
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static byte[] ProcessRequestByRpc(this SerslotServer data, ArraySegment<byte> arg_OriData)
         {
             HttpRequestFeature requestFeature = null;

+ 4 - 2
dotnet/ServiceStation/ApiLoader/Sers.Serslot/LocalApiNode.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.CompilerServices;
 using Newtonsoft.Json;
 using Sers.Core.Module.Api.ApiDesc;
 using Sers.Core.Module.Api.LocalApi;
@@ -18,10 +19,11 @@ namespace Sers.Serslot
         {
             this.apiDesc = apiDesc;
             this.server = server;
-        }       
+        }
 
 
-        public /*virtual*/ byte[] Invoke(ArraySegment<byte> arg_OriData)
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public byte[] Invoke(ArraySegment<byte> arg_OriData)
         {
             return server.ProcessRequestByRpc(arg_OriData);
         }