Skip to content

Commit 1e7c4e8

Browse files
authored
update beetlex to beetlex.light (#9095)
* update beetleX to BeetleX.Light * update beetlex to beetlex.light * fix fortunes error * fix error * remove beetlex-core-updb * update * update benchmark_config * update * update * update
1 parent 3f72bd5 commit 1e7c4e8

25 files changed

+491
-446
lines changed

frameworks/CSharp/beetlex/Benchmarks.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28010.2036
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.9.34728.123
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{12CA0190-5EA2-460F-ABC4-FAD454148EBF}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{8ACF83AD-E861-4642-BEF3-A6211F99389D}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{8ACF83AD-E861-4642-BEF3-A6211F99389D}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ServerGarbageCollection>true</ServerGarbageCollection>
77
</PropertyGroup>
88
<ItemGroup>
99
<PackageReference Include="BeetleX.FastHttpApi" Version="1.9.6" />
1010
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
11-
<PackageReference Include="Npgsql" Version="5.0.0-alpha1" />
12-
<PackageReference Include="SpanJson" Version="3.0.1" />
11+
<PackageReference Include="Npgsql" Version="8.0.3" />
1312
</ItemGroup>
1413
</Project>

frameworks/CSharp/beetlex/Benchmarks/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
using System.Threading;
77
using System.Text;
88
using BeetleX.Buffers;
9-
using SpanJson;
109
using System.Collections.Generic;
1110
using BeetleX.EventArgs;
11+
using System.Text.Json;
1212

1313
namespace Benchmarks
1414
{
@@ -109,8 +109,8 @@ public async virtual Task StartAsync(CancellationToken cancellationToken)
109109
mComplete.TrySetResult(new object());
110110
};
111111
mApiServer.Open();
112-
RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Delay Us=500;Write Coalescing Buffer Threshold Bytes=1000";
113-
//RawDb._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";
112+
RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
113+
//RawDb._connectionString = "Server=localhost;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
114114
await mComplete.Task;
115115
}
116116

@@ -140,7 +140,8 @@ public SpanJsonResult(object data)
140140

141141
public override void Write(PipeStream stream, HttpResponse response)
142142
{
143-
JsonSerializer.NonGeneric.Utf8.SerializeAsync(Data, stream);
143+
144+
JsonSerializer.Serialize(stream, Data); ;
144145
}
145146

146147

frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
using System.Runtime.Versioning;
88
using System.Text;
99
using System.Threading.Tasks;
10-
using System.Runtime.InteropServices.ComTypes;
11-
using BeetleX.EventArgs;
10+
1211
using Microsoft.Extensions.Caching.Memory;
1312
using Npgsql;
1413

14+
1515
namespace PlatformBenchmarks
1616
{
1717
public class RawDb
@@ -342,7 +342,6 @@ public static void Init()
342342
}
343343
}
344344
mInited = true;
345-
HttpServer.ApiServer.Log(LogType.Info, null, $"Init update commands cached");
346345
return;
347346
}
348347
}

frameworks/CSharp/beetlex/PlatformBenchmarks/GMTDate.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BeetleX.Buffers;
1+

2+
using BeetleX.Light.Memory;
23
using System;
34
using System.Collections.Generic;
45
using System.Text;
@@ -99,7 +100,7 @@ private ArraySegment<byte> GetData()
99100
return GetData(DateTime.Now);
100101
}
101102

102-
public void Write(PipeStream stream)
103+
public void Write(IStreamWriter stream)
103104
{
104105
var data = DATE;
105106
stream.Write(data.Array, 0, data.Count);
Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
using BeetleX;
2-
using BeetleX.Buffers;
3-
using SpanJson;
1+
using BeetleX.Light.Memory;
42
using System;
53
using System.Collections.Generic;
4+
using System.IO;
65
using System.Text;
6+
using System.Text.Json;
77
using System.Threading.Tasks;
88

99
namespace PlatformBenchmarks
1010
{
1111
public partial class HttpHandler
1212
{
13-
1413

15-
public async Task caching(string queryString, PipeStream stream, HttpToken token, ISession session)
14+
15+
public async Task caching(string queryString, IStreamWriter stream)
1616
{
1717
int count = 1;
1818
if (!string.IsNullOrEmpty(queryString))
@@ -30,20 +30,39 @@ public async Task caching(string queryString, PipeStream stream, HttpToken token
3030
count = 500;
3131
if (count < 1)
3232
count = 1;
33+
ContentLengthMemory content = new ContentLengthMemory();
3334
try
3435
{
35-
var data = await token.Db.LoadCachedQueries(count);
36+
var data = await _db.LoadCachedQueries(count);
3637
stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
37-
token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
38+
content.Data = GetContentLengthMemory(stream);
3839
GMTDate.Default.Write(stream);
39-
token.ContentPostion = stream.CacheLength;
40-
await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
40+
stream.WriteSequenceNetStream.StartWriteLength();
41+
42+
var jsonWriter = GetJsonWriter(stream);
43+
using (var unflush = stream.UnFlush())
44+
{
45+
jsonWriter.WriteStartArray();
46+
foreach (var item in data)
47+
{
48+
jsonWriter.WriteStartObject();
49+
jsonWriter.WriteNumber("Id", item.Id);
50+
jsonWriter.WriteNumber("RandomNumber", item.RandomNumber);
51+
jsonWriter.WriteEndObject();
52+
}
53+
jsonWriter.WriteEndArray();
54+
jsonWriter.Flush();
55+
56+
}
4157
}
4258
catch (Exception e_)
4359
{
44-
stream.Write(e_.Message);
60+
Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "caching", e_);
61+
stream.WriteString(e_.Message);
4562
}
46-
OnCompleted(stream, session, token);
63+
var len = stream.WriteSequenceNetStream.EndWriteLength();
64+
content.Full(len);
65+
4766
}
4867
}
4968
}

0 commit comments

Comments
 (0)