diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks.sln b/frameworks/CSharp/zysocket-v/PlatformBenchmarks.sln deleted file mode 100644 index 3879a0a6231..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29230.47 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{E4500562-635D-4DB9-99AE-B321F52A7C46}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E4500562-635D-4DB9-99AE-B321F52A7C46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E4500562-635D-4DB9-99AE-B321F52A7C46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E4500562-635D-4DB9-99AE-B321F52A7C46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E4500562-635D-4DB9-99AE-B321F52A7C46}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9FD9812E-E78B-4B9F-8526-8C85458ABA2E} - EndGlobalSection -EndGlobal diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/AsciiString.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/AsciiString.cs deleted file mode 100644 index 054160be587..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/AsciiString.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PlatformBenchmarks -{ - public readonly struct AsciiString : IEquatable - { - private readonly byte[] _data; - - public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s); - - public int Length => _data.Length; - - public byte[] Data => _data; - - public ReadOnlySpan AsSpan() => _data; - - public static implicit operator ReadOnlySpan(AsciiString str) => str._data; - public static implicit operator byte[](AsciiString str) => str._data; - - public static implicit operator AsciiString(string str) => new AsciiString(str); - - public static explicit operator string(AsciiString str) => str.ToString(); - - public bool Equals(AsciiString other) => ReferenceEquals(_data, other._data) || SequenceEqual(_data, other._data); - private bool SequenceEqual(byte[] data1, byte[] data2) => new Span(data1).SequenceEqual(data2); - - public static bool operator ==(AsciiString a, AsciiString b) => a.Equals(b); - public static bool operator !=(AsciiString a, AsciiString b) => !a.Equals(b); - public override bool Equals(object other) => (other is AsciiString) && Equals((AsciiString)other); - - public override int GetHashCode() - { - // Copied from x64 version of string.GetLegacyNonRandomizedHashCode() - // https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.Comparison.cs - var data = _data; - int hash1 = 5381; - int hash2 = hash1; - foreach (int b in data) - { - hash1 = ((hash1 << 5) + hash1) ^ b; - } - return hash1 + (hash2 * 1566083941); - } - - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ConcurrentRandom.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ConcurrentRandom.cs deleted file mode 100644 index a75abc3bb31..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ConcurrentRandom.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; - -namespace PlatformBenchmarks -{ - public class ConcurrentRandom - { - private static int nextSeed = 0; - - // Random isn't thread safe - [ThreadStatic] - private static Random _random; - - private static Random Random => _random ?? CreateRandom(); - - [MethodImpl(MethodImplOptions.NoInlining)] - private static Random CreateRandom() - { - _random = new Random(Interlocked.Increment(ref nextSeed)); - return _random; - } - - public int Next(int minValue, int maxValue) - { - return Random.Next(minValue, maxValue); - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/DBRaw.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/DBRaw.cs deleted file mode 100644 index 7af234af557..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/DBRaw.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Text; -using System.Threading.Tasks; - -namespace PlatformBenchmarks -{ - public class RawDb - { - - private readonly ConcurrentRandom _random; - - private readonly DbProviderFactory _dbProviderFactory; - - private readonly string _connectionString; - - public RawDb(ConcurrentRandom random, DbProviderFactory dbProviderFactory) - { - _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=192.168.1.55;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3"; - OnCreateCommand(); - } - - private void OnCreateCommand() - { - SingleCommand = new Npgsql.NpgsqlCommand(); - SingleCommand.CommandText = "SELECT id, randomnumber FROM world WHERE id = @Id"; - var id = SingleCommand.CreateParameter(); - id.ParameterName = "@Id"; - id.DbType = DbType.Int32; - id.Value = _random.Next(1, 10001); - SingleCommand.Parameters.Add(id); - FortuneCommand = new Npgsql.NpgsqlCommand(); - FortuneCommand.CommandText = "SELECT id, message FROM fortune"; - } - - private DbCommand SingleCommand; - - private DbCommand FortuneCommand; - - public async Task LoadSingleQueryRow() - { - using (var db = _dbProviderFactory.CreateConnection()) - { - db.ConnectionString = _connectionString; - await db.OpenAsync(); - SingleCommand.Connection = db; - SingleCommand.Parameters[0].Value = _random.Next(1, 10001); - return await ReadSingleRow(db, SingleCommand); - - } - } - - async Task ReadSingleRow(DbConnection connection, DbCommand cmd) - { - using (var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow)) - { - await rdr.ReadAsync(); - - return new World - { - Id = rdr.GetInt32(0), - RandomNumber = rdr.GetInt32(1) - }; - } - } - - public async Task LoadMultipleQueriesRows(int count) - { - using (var db = _dbProviderFactory.CreateConnection()) - { - db.ConnectionString = _connectionString; - await db.OpenAsync(); - return await LoadMultipleRows(count, db); - } - - } - - private async Task LoadMultipleRows(int count, DbConnection db) - { - SingleCommand.Connection = db; - SingleCommand.Parameters[0].Value = _random.Next(1, 10001); - var result = new World[count]; - for (int i = 0; i < result.Length; i++) - { - result[i] = await ReadSingleRow(db, SingleCommand); - SingleCommand.Parameters[0].Value = _random.Next(1, 10001); - } - return result; - - } - - public async Task> LoadFortunesRows() - { - var result = new List(); - - using (var db = _dbProviderFactory.CreateConnection()) - { - db.ConnectionString = _connectionString; - await db.OpenAsync(); - FortuneCommand.Connection = db; - using (var rdr = await FortuneCommand.ExecuteReaderAsync(CommandBehavior.CloseConnection)) - { - while (await rdr.ReadAsync()) - { - result.Add(new Fortune - { - Id = rdr.GetInt32(0), - Message = rdr.GetString(1) - }); - } - } - } - result.Add(new Fortune { Message = "Additional fortune added at request time." }); - result.Sort(); - return result; - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Fortune.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Fortune.cs deleted file mode 100644 index d970799d5ad..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Fortune.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PlatformBenchmarks -{ - public class Fortune : IComparable, IComparable - { - public int Id { get; set; } - - public string Message { get; set; } - - public int CompareTo(object obj) - { - return CompareTo((Fortune)obj); - } - - public int CompareTo(Fortune other) - { - // Performance critical, using culture insensitive comparison - return String.CompareOrdinal(Message, other.Message); - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/GMTDate.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/GMTDate.cs deleted file mode 100644 index 8cba0e9ae9c..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/GMTDate.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace PlatformBenchmarks -{ - internal class GMTDate - { - private List mWeekBuffers = new List(); - - public List mYears = new List(); - - public List mMoth = new List(); - - public List mNumber = new List(); - - private byte _1 = 58; - - private byte _s = 32; - - private byte _r = 13; - - private byte _n = 10; - - private byte[] GMT = new byte[3] - { - 71, - 77, - 84 - }; - - private static GMTDate mDefault; - - private Timer mUpdateTime; - - public static GMTDate Default - { - get - { - if (mDefault == null) - { - mDefault = new GMTDate(); - mDefault.Init(); - } - return mDefault; - } - } - - public ArraySegment DATE - { - get; - set; - } - - public GMTDate() - { - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Sun")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Mon")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Tue")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Wed")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Thu")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Fri")); - mWeekBuffers.Add(Encoding.ASCII.GetBytes("Sat")); - for (int j = 1970; j < 2470; j++) - { - mYears.Add(Encoding.ASCII.GetBytes(j.ToString())); - } - for (int i = 0; i <= 100; i++) - { - mNumber.Add(Encoding.ASCII.GetBytes(i.ToString("00"))); - } - mMoth.Add(Encoding.ASCII.GetBytes("Jan")); - mMoth.Add(Encoding.ASCII.GetBytes("Feb")); - mMoth.Add(Encoding.ASCII.GetBytes("Mar")); - mMoth.Add(Encoding.ASCII.GetBytes("Apr")); - mMoth.Add(Encoding.ASCII.GetBytes("May")); - mMoth.Add(Encoding.ASCII.GetBytes("Jun")); - mMoth.Add(Encoding.ASCII.GetBytes("Jul")); - mMoth.Add(Encoding.ASCII.GetBytes("Aug")); - mMoth.Add(Encoding.ASCII.GetBytes("Sep")); - mMoth.Add(Encoding.ASCII.GetBytes("Oct")); - mMoth.Add(Encoding.ASCII.GetBytes("Nov")); - mMoth.Add(Encoding.ASCII.GetBytes("Dec")); - } - - private void Init() - { - DATE = GetData(inLine: true); - mUpdateTime = new Timer(delegate - { - DATE = GetData(inLine: true); - }, null, 1000, 1000); - } - - private ArraySegment GetData(bool inLine = false) - { - return GetData(DateTime.Now, inLine); - } - - private ArraySegment GetData(DateTime date, bool inLine = false) - { - date = date.ToUniversalTime(); - int offset13 = 0; - byte[] GTM_BUFFER = new byte[50]; - Encoding.ASCII.GetBytes("Date: ", 0, 6, GTM_BUFFER, 0); - offset13 = 6; - byte[] buffer = GTM_BUFFER; - byte[] sub8 = mWeekBuffers[(int)date.DayOfWeek]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = sub8[2]; - offset13++; - buffer[offset13] = 44; - offset13++; - buffer[offset13] = _s; - offset13++; - sub8 = mNumber[date.Day]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = _s; - offset13++; - sub8 = mMoth[date.Month - 1]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = sub8[2]; - offset13++; - buffer[offset13] = _s; - offset13++; - sub8 = mYears[date.Year - 1970]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = sub8[2]; - offset13++; - buffer[offset13] = sub8[3]; - offset13++; - buffer[offset13] = _s; - offset13++; - sub8 = mNumber[date.Hour]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = _1; - offset13++; - sub8 = mNumber[date.Minute]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = _1; - offset13++; - sub8 = mNumber[date.Second]; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = _s; - offset13++; - sub8 = GMT; - buffer[offset13] = sub8[0]; - offset13++; - buffer[offset13] = sub8[1]; - offset13++; - buffer[offset13] = sub8[2]; - offset13++; - if (inLine) - { - buffer[offset13] = _r; - offset13++; - buffer[offset13] = _n; - offset13++; - } - return new ArraySegment(GTM_BUFFER, 0, offset13); - } - } - -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpHandler.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpHandler.cs deleted file mode 100644 index e0e11b7f93d..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpHandler.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using System.Buffers; -using System.Text; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - private static AsciiString _line = new AsciiString("\r\n"); - - private static AsciiString _2line = new AsciiString("\r\n\r\n"); - - private static AsciiString _httpsuccess = new AsciiString("HTTP/1.1 200 OK\r\n"); - - private static readonly AsciiString _headerServer = "Server: zysocket\r\n"; - - private static readonly AsciiString _headerContentLength = "Content-Length: "; - - private static readonly AsciiString _headerContentLengthZero = "Content-Length: 0\r\n"; - - private static readonly AsciiString _headerContentTypeText = "Content-Type: text/plain\r\n"; - - private static readonly AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8\r\n"; - - private static readonly AsciiString _headerContentTypeJson = "Content-Type: application/json\r\n"; - - private static readonly AsciiString _path_Json = "/json"; - - private static readonly AsciiString _path_Db = "/db"; - - private static readonly AsciiString _path_Queries = "/queries"; - - private static readonly AsciiString _path_Plaintext = "/plaintext"; - - private static readonly AsciiString _path_Fortunes = "/fortunes"; - - private static readonly AsciiString _result_plaintext = "Hello, World!"; - - private static readonly byte[] LenData = new byte[10] { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; - - private static byte _Space = 32; - - private static byte _question = 63; - - - public HttpHandler() - { - - } - - public void Default(IFiberRw fiberRw,ref WriteBytes write) - { - write.Write(" zysocket server
"); - write.Write($"error not found!"); - - var length = write.Stream.Length - fiberRw.UserToken.HttpHandlerPostion; - write.Stream.Position = fiberRw.UserToken.ContentPostion.postion; - write.Write(length.ToString(), false); - write.Flush(); - } - - private async Task OnCompleted(IFiberRw fiberRw, WriteBytes write) - { - Task WSend() - { - var length = write.Stream.Length - fiberRw.UserToken.HttpHandlerPostion; - write.Stream.Position = fiberRw.UserToken.ContentPostion.postion; - write.Write(length.ToString(), false); - write.Flush(false); - return fiberRw.Flush(); - } - - if (fiberRw.UserToken != null) - await await fiberRw.Sync.Ask(WSend); - } - - private int AnalysisUrl(ReadOnlySpan url) - { - for (int i = 0; i < url.Length; i++) - { - if (url[i] == _question) - return i; - } - return -1; - - } - - public async Task Receive(IFiberRw fiberRw, Memory memory_r, WriteBytes write) - { - var data = (await fiberRw.ReadLine(memory_r)); - ReadHander(fiberRw,ref data,ref write); - fiberRw.StreamReadFormat.Position = fiberRw.StreamReadFormat.Length; - } - - - private void ReadHander(IFiberRw fiberRw,ref Memory linedata,ref WriteBytes write) - { - - var token = fiberRw.UserToken; - ReadOnlySpan line = linedata.Span; - ReadOnlySpan url = line; - - int offset2 = 0; - int count = 0; - for (int i = 0; i < line.Length; i++) - { - if (line[i] == _Space) - { - if (count != 0) - { - url = line.Slice(offset2, i - offset2); - break; - } - offset2 = i + 1; - count++; - } - } - - - int queryIndex = AnalysisUrl(url); - ReadOnlySpan queryString = default; - ReadOnlySpan baseUrl; - if (queryIndex > 0) - { - baseUrl = url.Slice(0, queryIndex); - queryString = url.Slice(queryIndex + 1, url.Length - queryIndex - 1); - } - else - { - baseUrl = url; - } - OnWriteHeader(ref write); - - if (baseUrl.Length == _path_Plaintext.Length && baseUrl.StartsWith(_path_Plaintext)) - { - write.Write(_headerContentTypeText.Data, 0, _headerContentTypeText.Length); - OnWriteContentLength(write, token); - Plaintext(fiberRw, write); - } - else if (baseUrl.Length == _path_Json.Length && baseUrl.StartsWith(_path_Json)) - { - write.Write(_headerContentTypeJson.Data, 0, _headerContentTypeJson.Length); - OnWriteContentLength(write, token); - Json(fiberRw, write); - } - else if (baseUrl.Length == _path_Db.Length && baseUrl.StartsWith(_path_Db)) - { - write.Write(_headerContentTypeJson.Data, 0, _headerContentTypeJson.Length); - OnWriteContentLength(write, token); - db(fiberRw, write); - } - else if (baseUrl.Length == _path_Queries.Length && baseUrl.StartsWith(_path_Queries)) - { - write.Write(_headerContentTypeJson.Data, 0, _headerContentTypeJson.Length); - OnWriteContentLength(write, token); - queries(Encoding.ASCII.GetString(queryString),fiberRw, write); - } - else if (baseUrl.Length == _path_Fortunes.Length && baseUrl.StartsWith(_path_Fortunes)) - { - write.Write(_headerContentTypeHtml.Data, 0, _headerContentTypeHtml.Length); - OnWriteContentLength(write, token); - fortunes(fiberRw, write); - } - else - { - write.Write(_headerContentTypeHtml.Data, 0, _headerContentTypeHtml.Length); - OnWriteContentLength(write, token); - Default( fiberRw, ref write); - } - - } - - - private void OnWriteHeader(ref WriteBytes write) - { - write.Write(_httpsuccess.Data, 0, _httpsuccess.Length); - write.Write(_headerServer.Data, 0, _headerServer.Length); - ArraySegment date = GMTDate.Default.DATE; - write.Write(date.Array, date.Offset, date.Count); - } - - - - private void OnWriteContentLength(WriteBytes write, HttpToken token) - { - write.Write(_headerContentLength.Data, 0, _headerContentLength.Length); - token.ContentPostion = write.Allocate(LenData); - write.Write(_2line, 0, 4); - token.HttpHandlerPostion = (int)write.Stream.Position; - } - - - - - - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpToken.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpToken.cs deleted file mode 100644 index a1dff0166e6..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/HttpToken.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace PlatformBenchmarks -{ - public class HttpToken - { - public (int postion, int size) ContentPostion { get; set; } - public long HttpHandlerPostion { get; set; } - public RawDb Db { get; set; } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/JsonMessage.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/JsonMessage.cs deleted file mode 100644 index 5a2e3b27c8e..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/JsonMessage.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PlatformBenchmarks -{ - public struct JsonMessage - { - public string message - { - get; - set; - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/PlatformBenchmarks.csproj deleted file mode 100644 index 90f99f0507b..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/PlatformBenchmarks.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - Exe - netcoreapp3.0 - 8.0 - true - - - - - - - - - - diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Program.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Program.cs deleted file mode 100644 index 3ca384da857..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Program.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System; - -namespace PlatformBenchmarks -{ - class Program - { - public static void Main(string[] args) - { - new HostBuilder().ConfigureServices(delegate (HostBuilderContext hostContext, IServiceCollection services) - { - services.AddHostedService(); - - }).Build().Run(); - - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Properties/PublishProfiles/FolderProfile.pubxml b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Properties/PublishProfiles/FolderProfile.pubxml deleted file mode 100644 index d0d006df42c..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/Properties/PublishProfiles/FolderProfile.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - FileSystem - Release - Any CPU - net5.0 - bin\Release\netcoreapp2.2\publish\ - - \ No newline at end of file diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/World.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/World.cs deleted file mode 100644 index 7a0c4567e27..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/World.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -namespace PlatformBenchmarks -{ - [StructLayout(LayoutKind.Sequential, Size = 8)] - public struct World - { - public int Id { get; set; } - - public int RandomNumber { get; set; } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ZYHttpServer.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ZYHttpServer.cs deleted file mode 100644 index ff7fd9ce3cc..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/ZYHttpServer.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.Server; -using ZYSocket.Server.Builder; - -namespace PlatformBenchmarks -{ - public class ZYHttpServer : IHostedService - { - public ISocketServer SocketServer { get; private set; } - public IServiceProvider serviceProvider { get; private set; } - - public HttpHandler @HttpHandler { get; private set; } - - public ZYHttpServer() - { - ArraySegment date = GMTDate.Default.DATE; - var containerBuilder = new ServiceCollection(); - new SockServBuilder(containerBuilder, p => - { - return new ZYSocketSuper(p) - { - BinaryInput = new BinaryInputHandler(BinaryInputHandler), - Connetions = new ConnectionFilter(ConnectionFilter), - MessageInput = new DisconnectHandler(DisconnectHandler) - }; - }) - .ConfigServer(p => - { - p.Port = 8080; - p.MaxBufferSize = 1024; - p.MaxConnectCout = 20000; - }); - - serviceProvider = containerBuilder.BuildServiceProvider(); - SocketServer = serviceProvider.GetRequiredService(); - @HttpHandler = new HttpHandler(); - } - - - public Task StartAsync(CancellationToken cancellationToken) - { - SocketServer.Start(); - return Task.CompletedTask; - } - - public Task StopAsync(CancellationToken cancellationToken) - { - SocketServer.Stop(); - return Task.CompletedTask; - } - - bool ConnectionFilter(ISockAsyncEvent socketAsync) => true; - - void DisconnectHandler(string message, ISockAsyncEvent socketAsync, int erorr) - { - socketAsync.UserToken = null; - socketAsync.AcceptSocket.Dispose(); - } - - - async void BinaryInputHandler(ISockAsyncEvent socketAsync) - { - var fiberRw = await socketAsync.GetFiberRw(); - fiberRw.UserToken = new HttpToken - { - Db = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance) - }; - - using var data_r = fiberRw.GetMemory(1024); - using var write = new WriteBytes(fiberRw); - for (; ; ) - { - await HttpHandler.Receive(fiberRw, data_r.Memory, write); - } - - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/db.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/db.cs deleted file mode 100644 index 9a2fac87c71..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/db.cs +++ /dev/null @@ -1,29 +0,0 @@ - -using Swifter.Json; -using System; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - - public async void db(IFiberRw fiberRw, WriteBytes write) - { - try - { - var data = await fiberRw.UserToken.Db.LoadSingleQueryRow(); - await JsonFormatter.SerializeObjectAsync(data, write.Stream, System.Text.Encoding.UTF8); - } - catch (Exception e_) - { - write.Write(e_.Message); - } - - await OnCompleted(fiberRw, write); - - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/fortunes.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/fortunes.cs deleted file mode 100644 index 643ddb541d8..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/fortunes.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - - private readonly static AsciiString _fortunesTableStart = "Fortunes"; - private readonly static AsciiString _fortunesRowStart = ""; - private readonly static AsciiString _fortunesTableEnd = "
idmessage
"; - private readonly static AsciiString _fortunesColumn = ""; - private readonly static AsciiString _fortunesRowEnd = "
"; - - public async void fortunes(IFiberRw fiberRw, WriteBytes write) - { - - - try - { - var data = await fiberRw.UserToken.Db.LoadFortunesRows(); - - Task WSend() - { - write.Write(_fortunesTableStart.Data, 0, _fortunesTableStart.Length); - foreach (var item in data) - { - write.Write(_fortunesRowStart.Data, 0, _fortunesRowStart.Length); - write.Write(item.Id.ToString(CultureInfo.InvariantCulture),false); - write.Write(_fortunesColumn.Data, 0, _fortunesColumn.Length); - write.Write(System.Web.HttpUtility.HtmlEncode(item.Message),false); - write.Write(_fortunesRowEnd.Data, 0, _fortunesRowEnd.Length); - } - write.Write(_fortunesTableEnd.Data, 0, _fortunesTableEnd.Length); - - var length = write.Stream.Length - fiberRw.UserToken.HttpHandlerPostion; - write.Stream.Position = fiberRw.UserToken.ContentPostion.postion; - write.Write(length.ToString(), false); - write.Flush(false); - return fiberRw.Flush(); - } - if (fiberRw.UserToken != null) - await await fiberRw.Sync.Ask(WSend); - } - catch (Exception e_) - { - write.Write(e_.Message); - await OnCompleted(fiberRw, write); - } - - - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/json.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/json.cs deleted file mode 100644 index ffae41e70b6..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/json.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Swifter.Json; -using System; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - public async void Json(IFiberRw fiberRw,WriteBytes write) - { - JsonMessage jsonMessage = default(JsonMessage); - jsonMessage.message = "Hello, World!"; - JsonFormatter.SerializeObject(jsonMessage,write.Stream,System.Text.Encoding.UTF8); - var length = write.Stream.Length - fiberRw.UserToken.HttpHandlerPostion; - write.Stream.Position = fiberRw.UserToken.ContentPostion.postion; - write.Write(length.ToString(), false); - await write.Flush(); - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/plaintext.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/plaintext.cs deleted file mode 100644 index 3975047e5b9..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/plaintext.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Threading.Tasks; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - public async void Plaintext( IFiberRw fiberRw, WriteBytes write) - { - write.Write(_result_plaintext.Data, 0, _result_plaintext.Length); - var length = write.Stream.Length - fiberRw.UserToken.HttpHandlerPostion; - write.Stream.Position = fiberRw.UserToken.ContentPostion.postion; - write.Write(length.ToString(), false); - await write.Flush(); - } - } -} diff --git a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/queries.cs b/frameworks/CSharp/zysocket-v/PlatformBenchmarks/queries.cs deleted file mode 100644 index 5d6ed0ee6a6..00000000000 --- a/frameworks/CSharp/zysocket-v/PlatformBenchmarks/queries.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Swifter.Json; -using System; -using ZYSocket; -using ZYSocket.FiberStream; - -namespace PlatformBenchmarks -{ - public partial class HttpHandler - { - public async void queries(string queryString, IFiberRw fiberRw, WriteBytes write) - { - int count = 1; - if (!string.IsNullOrEmpty(queryString)) - { - var values = queryString.Split('='); - if (values.Length > 1) - { - if (int.TryParse(values[1], out int size)) - { - count = size; - } - } - } - if (count > 500) - count = 500; - if (count < 1) - count = 1; - try - { - var data = await fiberRw.UserToken.Db.LoadMultipleQueriesRows(count); - - await JsonFormatter.SerializeObjectAsync(data, write.Stream, System.Text.Encoding.UTF8); - } - catch (Exception e_) - { - write.Write(e_.Message); - } - await OnCompleted(fiberRw, write); - } - } -} diff --git a/frameworks/CSharp/zysocket-v/README.md b/frameworks/CSharp/zysocket-v/README.md deleted file mode 100644 index 967311371e7..00000000000 --- a/frameworks/CSharp/zysocket-v/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# [ZYSOCKET-V](https://github.com/luyikk/zysocket-v)(.Net) Benchmarking Test -This includes tests for plaintext, json, db. - -## Infrastructure Software Versions -**Language** - -* C# 7.2 - -**Platforms** - -* .NET Core (Windows and Linux) - -**Web Servers** - -* [ZYSOCKET-V](https://github.com/luyikk/zysocket-v) - -## Paths & Source for Tests - -* [Plaintext](PlatformBenchmarks/Program.cs): "/plaintext" -* [JSON Serialization](PlatformBenchmarks/Program.cs): "/json" -* [Single query](PlatformBenchmarks/Program.cs): "/db" -* [Multiple query](PlatformBenchmarks/Program.cs): "/queries" -* [Fortune](PlatformBenchmarks/Program.cs): "/fortune" diff --git a/frameworks/CSharp/zysocket-v/benchmark_config.json b/frameworks/CSharp/zysocket-v/benchmark_config.json deleted file mode 100644 index d2d83161b68..00000000000 --- a/frameworks/CSharp/zysocket-v/benchmark_config.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "framework": "zysocket-v", - "tests": [ - { - "default": { - "fortune_url": "/fortunes", - "plaintext_url": "/plaintext", - "json_url": "/json", - "db_url": "/db", - "query_url": "/queries?queries=", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "Postgres", - "framework": "zysocket-v", - "language": "C#", - "orm": "Raw", - "platform": ".NET", - "flavor": "CoreCLR", - "webserver": "zysocket-v", - "os": "Linux", - "database_os": "Linux", - "display_name": "zysocket-v", - "notes": "", - "versus": "aspcore-mvc" - } - } - ] -} diff --git a/frameworks/CSharp/zysocket-v/config.toml b/frameworks/CSharp/zysocket-v/config.toml deleted file mode 100644 index b21e6a223c6..00000000000 --- a/frameworks/CSharp/zysocket-v/config.toml +++ /dev/null @@ -1,18 +0,0 @@ -[framework] -name = "zysocket-v" - -[main] -urls.plaintext = "/plaintext" -urls.json = "/json" -urls.db = "/db" -urls.query = "/queries?queries=" -urls.fortune = "/fortunes" -approach = "Realistic" -classification = "Fullstack" -database = "Postgres" -database_os = "Linux" -os = "Linux" -orm = "Raw" -platform = ".NET" -webserver = "zysocket-v" -versus = "aspcore-mvc" diff --git a/frameworks/CSharp/zysocket-v/zysocket-v.dockerfile b/frameworks/CSharp/zysocket-v/zysocket-v.dockerfile deleted file mode 100644 index 9739314dda6..00000000000 --- a/frameworks/CSharp/zysocket-v/zysocket-v.dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build -WORKDIR /app -COPY PlatformBenchmarks . -RUN dotnet publish -c Release -o out - -FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime -ENV COMPlus_ReadyToRun 0 -WORKDIR /app -COPY --from=build /app/out ./ - -EXPOSE 8080 - -ENTRYPOINT ["dotnet", "PlatformBenchmarks.dll"]