Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
丁松杰
/
Pole
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
07435322
authored
Feb 24, 2020
by
dingsongjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加性能测试
parent
9a03c2ae
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
12 deletions
Pole.sln
samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs
samples/apis/Backet.Api/Properties/launchSettings.json
samples/apis/Backet.Api/appsettings.json
src/Pole.Core/Serialization/EventTypeFinder.cs
src/Pole.EventBus.Rabbitmq/Consumer/ConsumerRunner.cs
test/Pole.Core.Test/Pole.Core.Test.csproj
test/Pole.Samples.Backet.Api/Benchmarks/GrainWithEntityframeworkCoreAndPgTest.cs
test/Pole.Samples.Backet.Api/Pole.Samples.Backet.Api.csproj
test/Pole.Samples.Backet.Api/Program.cs
Pole.sln
View file @
07435322
...
...
@@ -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}
...
...
samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs
View file @
07435322
...
...
@@ -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
)
;
}
}
}
samples/apis/Backet.Api/Properties/launchSettings.json
View file @
07435322
...
...
@@ -2,7 +2,7 @@
"profiles"
:
{
"Backet.Api"
:
{
"commandName"
:
"Project"
,
"applicationUrl"
:
"http://localhost:500
1
"
,
"applicationUrl"
:
"http://localhost:500
0
"
,
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
}
...
...
samples/apis/Backet.Api/appsettings.json
View file @
07435322
...
...
@@ -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"
:
{
...
...
src/Pole.Core/Serialization/EventTypeFinder.cs
View file @
07435322
...
...
@@ -30,9 +30,9 @@ namespace Pole.Core.Serialization
{
eventCode
=
attribute
.
EventName
;
}
typeDict
.
TryAdd
(
type
,
type
.
FullNam
e
);
typeDict
.
TryAdd
(
type
,
eventCod
e
);
if
(!
codeDict
.
TryAdd
(
type
.
FullNam
e
,
type
))
if
(!
codeDict
.
TryAdd
(
eventCod
e
,
type
))
{
throw
new
TypeCodeRepeatedException
(
type
.
FullName
,
type
.
FullName
);
}
...
...
src/Pole.EventBus.Rabbitmq/Consumer/ConsumerRunner.cs
View file @
07435322
...
...
@@ -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
);
...
...
test/Pole.Core.Test/Pole.Core.Test.csproj
View file @
07435322
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
...
...
test/Pole.Samples.Backet.Api/Benchmarks/GrainWithEntityframeworkCoreAndPgTest.cs
0 → 100644
View file @
07435322
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"
);
}
}
}
}
test/Pole.Samples.Backet.Api/Pole.Samples.Backet.Api.csproj
0 → 100644
View file @
07435322
<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>
test/Pole.Samples.Backet.Api/Program.cs
0 → 100644
View file @
07435322
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
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment