Browse Source

update beetlex to 1.4.0 (#5069)

* docker add COMPlus_ReadyToRun variable
update beetlex

* update beetlex, enabled thread queue

* beetlex framework add db and queries cases

* add db code

* change result json data

* update query url

* beetlex framework add fortunes cases

* change Content-Type

* add beetlex core cases

* fix queries cases

* update config

* change try readline

* update benchmark config

* Update README.md

* Update README.md

* change versus property

* beetlex-core update .net core to v3.0

* change beetlex-core project file

* beetlex update raw db class

* beetlex update raw db

* beetlex debug plaintext

* change debug docker file

* update beetlex to 1.4.0

* update
Henry 5 years ago
parent
commit
ac36a01364

+ 8 - 2
frameworks/CSharp/beetlex/Benchmarks/Program.cs

@@ -8,6 +8,7 @@ using System.Text;
 using BeetleX.Buffers;
 using SpanJson;
 using System.Collections.Generic;
+using BeetleX.EventArgs;
 
 namespace Benchmarks
 {
@@ -77,7 +78,7 @@ namespace Benchmarks
 
         private HttpApiServer mApiServer;
 
-        public virtual Task StartAsync(CancellationToken cancellationToken)
+        public async virtual Task StartAsync(CancellationToken cancellationToken)
         {
             plaintextResult = new StringBytes(_helloWorldPayload);
             mApiServer = new HttpApiServer();
@@ -94,7 +95,12 @@ namespace Benchmarks
                 e.Session["DB"] = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance);
             };
             mApiServer.Open();
-            return Task.CompletedTask;
+            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
+            var response = await client.GetAsync("http://localhost:8080/json");
+            mApiServer.BaseServer.Log(LogType.Info, null, $"Get josn {response.StatusCode}");
+            response = await client.GetAsync("http://localhost:8080/plaintext");
+            mApiServer.BaseServer.Log(LogType.Info, null, $"Get plaintext {response.StatusCode}");
+          
         }
 
         public virtual Task StopAsync(CancellationToken cancellationToken)

+ 1 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs

@@ -20,7 +20,7 @@ namespace PlatformBenchmarks
         {
             _random = random;
             _dbProviderFactory = dbProviderFactory;
-            _connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
+           _connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
             //_connectionString = "Server=192.168.2.19;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
             OnCreateCommand();
         }

+ 26 - 22
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs

@@ -106,34 +106,37 @@ namespace PlatformBenchmarks
 
         private void OnProcess(PipeStream pipeStream,HttpToken token,ISession sessino)
         {
-
-            var result = pipeStream.IndexOf(_line.Data);
-            if (result.End == null)
-            {
-                return;
-            }
-            int len = result.Length;
-            pipeStream.Read(token.Buffer, 0, len);
-            ReadOnlySpan<byte> line = new Span<byte>(token.Buffer, 0, len);
-            ReadOnlySpan<byte> http = line;
-            ReadOnlySpan<byte> method = line;
-            ReadOnlySpan<byte> url = line;
+            var line = _line.AsSpan();
+            int len = (int)pipeStream.FirstBuffer.Length;
+            var receiveData = pipeStream.FirstBuffer.Memory.Span;      
+            ReadOnlySpan<byte> http= line;
+            ReadOnlySpan<byte> method= line;
+            ReadOnlySpan<byte> url= line;
             int offset2 = 0;
             int count = 0;
-            for (int i = 0; i < line.Length; i++)
+            for(int i=0;i<len;i++)
             {
-                if (line[i] == _Space)
+                if(receiveData[i]==line[0])
                 {
-                    if (count != 0)
+                    http = receiveData.Slice(offset2, i - offset2);
+                    break;
+                }
+                else
+                {
+                    if (receiveData[i] == _Space)
                     {
-                        url = line.Slice(offset2, i - offset2);
-                        offset2 = i + 1;
-                        http = line.Slice(offset2, line.Length - offset2 - 2);
-                        break;
+                        if (count != 0)
+                        {
+                            url = receiveData.Slice(offset2, i - offset2);
+                            offset2 = i + 1;
+                        }
+                        else
+                        {
+                            method = receiveData.Slice(offset2, i - offset2);
+                            offset2 = i + 1;
+                            count++;
+                        }
                     }
-                    method = line.Slice(offset2, i - offset2);
-                    offset2 = i + 1;
-                    count++;
                 }
             }
             OnStartLine(http, method, url, sessino, token, pipeStream);
@@ -141,6 +144,7 @@ namespace PlatformBenchmarks
 
         public override void SessionReceive(IServer server, SessionReceiveEventArgs e)
         {
+
             base.SessionReceive(server, e);
             PipeStream pipeStream = e.Session.Stream.ToPipeStream();
             HttpToken token = (HttpToken)e.Session.Tag;

+ 9 - 6
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpServer.cs

@@ -13,21 +13,24 @@ namespace PlatformBenchmarks
     {
         private IServer mApiServer;
 
-        public virtual Task StartAsync(CancellationToken cancellationToken)
+        public virtual async Task StartAsync(CancellationToken cancellationToken)
         {
             ArraySegment<byte> date = GMTDate.Default.DATE;
             ServerOptions serverOptions = new ServerOptions();
             serverOptions.LogLevel = LogType.Error;
             serverOptions.DefaultListen.Port = 8080;
             serverOptions.Statistical = false;
-            serverOptions.BufferSize = 1024 * 4;
-            serverOptions.PrivateBufferPool = true;
-            serverOptions.MaxConnections = 100000;
+            serverOptions.BufferSize = 2048;
             serverOptions.BufferPoolMaxMemory = 1000;
+            serverOptions.BufferPoolSize = 1024 * 4;
             mApiServer = SocketFactory.CreateTcpServer<HttpHandler>(serverOptions);
             mApiServer.Open();
-            mApiServer.Log(LogType.Info,null, $"Debug mode [{Program.Debug}]");
-            return Task.CompletedTask;
+            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
+            var response = await client.GetAsync("http://localhost:8080/json");
+            mApiServer.Log(LogType.Info, null, $"Get josn {response.StatusCode}");
+            response = await client.GetAsync("http://localhost:8080/plaintext");
+            mApiServer.Log(LogType.Info, null, $"Get plaintext {response.StatusCode}");
+            mApiServer.Log(LogType.Info, null, $"Debug mode [{Program.Debug}]");
         }
 
         public virtual Task StopAsync(CancellationToken cancellationToken)

+ 2 - 8
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs

@@ -7,13 +7,7 @@ namespace PlatformBenchmarks
 {
     public class HttpToken
     {
-        private byte[] mLengthBuffer = new byte[10];
-
-        public byte[] Buffer
-        {
-            get;
-            private set;
-        }       
+        private byte[] mLengthBuffer = new byte[10];   
 
         public RawDb Db { get; set; }
 
@@ -21,7 +15,7 @@ namespace PlatformBenchmarks
 
         public HttpToken()
         {
-            Buffer = new byte[2048];
+            
         }
 
         public byte[] GetLengthBuffer(string length)

+ 1 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj

@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="BeetleX" Version="1.3.2" />
+    <PackageReference Include="BeetleX" Version="1.4.0.1" />
     <PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
     <PackageReference Include="Npgsql" Version="4.0.7" />
     <PackageReference Include="SpanJson" Version="2.0.14" />