Commit 07435322 by dingsongjie

添加性能测试

parent 9a03c2ae
......@@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.EventStorage.PostgreSq
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.Orleans.Provider.EntityframeworkCore", "src\Pole.Orleans.Provider.EntityframeworkCore\Pole.Orleans.Provider.EntityframeworkCore.csproj", "{0DA75F4A-BF47-4B52-B932-48BB6A709934}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pole.Samples.Backet.Api", "test\Pole.Samples.Backet.Api\Pole.Samples.Backet.Api.csproj", "{FB3D2F52-123A-4606-B682-9159BD7913AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -93,6 +95,10 @@ Global
{0DA75F4A-BF47-4B52-B932-48BB6A709934}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DA75F4A-BF47-4B52-B932-48BB6A709934}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DA75F4A-BF47-4B52-B932-48BB6A709934}.Release|Any CPU.Build.0 = Release|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -113,6 +119,7 @@ Global
{23EA8735-DB2E-4599-8902-8FCBCBE4799C} = {655E719B-4A3E-467C-A541-E0770AB81DE1}
{548EFDBB-252F-48DD-87F4-58ABFBD4963C} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
{0DA75F4A-BF47-4B52-B932-48BB6A709934} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
{FB3D2F52-123A-4606-B682-9159BD7913AE} = {655E719B-4A3E-467C-A541-E0770AB81DE1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB0775A3-F293-4043-ADB7-72BAC081E87E}
......
......@@ -10,14 +10,14 @@ namespace Backet.Api.EventHandlers
{
public class ToNoticeBacketCreatedEventHandler : PoleEventHandler<BacketCreatedEvent>, IToNoticeBacketCreatedEventHandler
{
public Task BulkEventsHandle(List<BacketCreatedEvent> @event)
public async Task BulkEventsHandle(List<BacketCreatedEvent> @event)
{
return Task.CompletedTask;
await Task.Delay(1500);
}
public Task EventHandle(BacketCreatedEvent @event)
public async Task EventHandle(BacketCreatedEvent @event)
{
return Task.CompletedTask;
await Task.Delay(1200);
}
}
}
......@@ -2,7 +2,7 @@
"profiles": {
"Backet.Api": {
"commandName": "Project",
"applicationUrl": "http://localhost:5001",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -8,13 +8,13 @@
}
},
"postgres": {
"write": "Server=192.168.0.41;Port=5432;Username=postgres;Password=comteck2020!@#;Database=Pole-Backet;Enlist=True;Timeout=0;Command Timeout=600;Pooling=false;MinPoolSize=20;MaxPoolSize=500;"
"write": "Server=192.168.0.248;Port=5432;Username=postgres;Password=comteck2020!@#;Database=Pole-Backet;Enlist=True;Timeout=0;Command Timeout=600;Pooling=false;MinPoolSize=20;MaxPoolSize=500;"
},
"ServiceName": "Backet",
"RabbitmqConfig": {
"HostAddress": "192.168.0.41",
"HostUserName": "test",
"HostPassword": "test"
"HostAddress": "192.168.0.248",
"HostUserName": "comteck",
"HostPassword": "comteck3030"
}
//"Kestrel": {
// "EndpointDefaults": {
......
......@@ -30,9 +30,9 @@ namespace Pole.Core.Serialization
{
eventCode = attribute.EventName;
}
typeDict.TryAdd(type, type.FullName);
typeDict.TryAdd(type, eventCode);
if (!codeDict.TryAdd(type.FullName, type))
if (!codeDict.TryAdd(eventCode, type))
{
throw new TypeCodeRepeatedException(type.FullName, type.FullName);
}
......
......@@ -121,6 +121,7 @@ namespace Pole.EventBus.RabbitMQ
private async Task ProcessComsumerErrors(BasicDeliverEventArgs ea, Exception exception)
{
// todo 这里需要添加断路器 防止超量的 Task.Delay
if (ea.BasicProperties.Headers.TryGetValue(Consts.ConsumerRetryTimesStr, out object retryTimesObj))
{
var retryTimesStr = Encoding.UTF8.GetString((byte[])retryTimesObj);
......
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
......
using Backet.Api.Infrastructure;
using BenchmarkDotNet.Attributes;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Pole.Samples.Backet.Api.Benchmarks
{
public class GrainWithEntityframeworkCoreAndPgTest
{
IServiceProvider serviceProvider;
public GrainWithEntityframeworkCoreAndPgTest()
{
var services = new ServiceCollection();
services.AddDbContextPool<BacketDbContext>(options => options.UseNpgsql("Server=192.168.0.248;Port=5432;Username=postgres;Password=comteck2020!@#;Database=Pole-Backet;Enlist=True;Timeout=0;Command Timeout=600;Pooling=false;MinPoolSize=20;MaxPoolSize=500;"));
serviceProvider = services.BuildServiceProvider();
}
[Benchmark]
public async Task SingleOrDefaultAsync()
{
using (var scope = serviceProvider.CreateScope())
{
var context = scope.ServiceProvider.GetRequiredService<BacketDbContext>();
var entity = await context.Backets.Include(box => box.BacketItems).SingleOrDefaultAsync(m => m.Id == "222");
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\samples\apis\Backet.Api\Backet.Api.csproj" />
</ItemGroup>
</Project>
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using Pole.Samples.Backet.Api.Benchmarks;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Pole.Samples.Backet.Api
{
public class Program
{
public static async Task Main(string[] args)
{
//GrainWithEntityframeworkCoreAndPgTest grainWithEntityframeworkCoreAndPgTest = new GrainWithEntityframeworkCoreAndPgTest();
//await grainWithEntityframeworkCoreAndPgTest.SingleOrDefaultAsync();
Summary summary = BenchmarkRunner.Run<GrainWithEntityframeworkCoreAndPgTest>();
Console.ReadLine();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment