Skip to content

Commit

Permalink
Merge pull request #2 from PandaTechAM/development
Browse files Browse the repository at this point in the history
updated nugets
  • Loading branch information
HaikAsatryan authored May 26, 2024
2 parents 54572c6 + f93dafc commit ecaf089
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>Pandatech</Authors>
<Copyright>MIT</Copyright>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<PackageId>Pandatech.EFCore.PostgresExtensions</PackageId>
<Title>Pandatech.EFCore.PostgresExtensions</Title>
<PackageTags>Pandatech, library, EntityFrameworkCore, PostgreSQL, For Update, Lock, LockingSyntax, Bulk insert, BinaryCopy</PackageTags>
<Description>The Pandatech.EFCore.PostgresExtensions library enriches Entity Framework Core applications with advanced PostgreSQL functionalities, starting with the ForUpdate locking syntax and BulkInsert function. Designed for seamless integration, this NuGet package aims to enhance the efficiency and capabilities of EF Core models when working with PostgreSQL, with the potential for further PostgreSQL-specific extensions.</Description>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-efcore-postgres-extensions</RepositoryUrl>
<PackageReleaseNotes>Npgsql copy feature</PackageReleaseNotes>
<PackageReleaseNotes>NuGet updates</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion test/PandaNuGet.Demo/Dtos/BulkBenchmarkResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public enum BenchmarkMethod
{
EFCore,
Dapper,
NpgsqlCopy
NpgsqlCopy,
ExternalBulkInsert
}
1 change: 1 addition & 0 deletions test/PandaNuGet.Demo/PandaNuGet.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="EFCore.BulkExtensions.PostgreSql" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
Expand Down
12 changes: 9 additions & 3 deletions test/PandaNuGet.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
var results = new List<BulkBenchmarkResponse>
{
service.BulkInsertEfCore(minimumRows),
service.BulkInsertNpgsqlCopy(minimumRows),
service.BulkInsertDapper(minimumRows),
service.BulkInsertNpgsqlCopy(minimumRows),
service.BulkInsertExternal(minimumRows),
service.BulkInsertEfCore(minimumRows * 10),
service.BulkInsertDapper(minimumRows * 10),
service.BulkInsertNpgsqlCopy(minimumRows * 10),
service.BulkInsertExternal(minimumRows * 10),
service.BulkInsertEfCore(minimumRows * 100),
service.BulkInsertDapper(minimumRows * 100),
service.BulkInsertNpgsqlCopy(minimumRows * 100)
service.BulkInsertNpgsqlCopy(minimumRows * 100),
service.BulkInsertExternal(minimumRows * 100)
};

return results;
Expand All @@ -44,12 +47,15 @@
await service.BulkInsertEfCoreAsync(minimumRows),
await service.BulkInsertDapperAsync(minimumRows),
await service.BulkInsertNpgsqlCopyAsync(minimumRows),
await service.BulkInsertExternalAsync(minimumRows),
await service.BulkInsertEfCoreAsync(minimumRows * 10),
await service.BulkInsertDapperAsync(minimumRows * 10),
await service.BulkInsertNpgsqlCopyAsync(minimumRows * 10),
await service.BulkInsertExternalAsync(minimumRows * 10),
await service.BulkInsertEfCoreAsync(minimumRows * 100),
await service.BulkInsertDapperAsync(minimumRows * 100),
await service.BulkInsertNpgsqlCopyAsync(minimumRows * 100)
await service.BulkInsertNpgsqlCopyAsync(minimumRows * 100),
await service.BulkInsertExternalAsync(minimumRows * 100)
};

return results;
Expand Down
37 changes: 37 additions & 0 deletions test/PandaNuGet.Demo/Services/BulkInsertService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Text;
using Dapper;
using EFCore.BulkExtensions;
using EFCore.PostgresExtensions.Extensions.BulkInsertExtension;
using Microsoft.EntityFrameworkCore;
using PandaNuGet.Demo.Context;
Expand Down Expand Up @@ -208,6 +209,42 @@ public async Task<BulkBenchmarkResponse> BulkInsertDapperAsync(int rowsCount, bo
return new BulkBenchmarkResponse(BenchmarkMethod.Dapper, rowsCount, stopwatch.ElapsedMilliseconds.ToString());
}

public async Task<BulkBenchmarkResponse> BulkInsertExternalAsync(int rowsCount, bool ignoreReset = false)
{
await ResetDbAsync(ignoreReset);
var users = new List<UserEntity>();

for (int i = 0; i < rowsCount; i++)
{
users.Add(new UserEntity());
}

var stopwatch = Stopwatch.StartNew();
await dbContext.BulkInsertAsync(users);
stopwatch.Stop();

return new BulkBenchmarkResponse(BenchmarkMethod.ExternalBulkInsert, rowsCount,
stopwatch.ElapsedMilliseconds.ToString());
}

public BulkBenchmarkResponse BulkInsertExternal(int rowsCount, bool ignoreReset = false)
{
ResetDb(ignoreReset);
var users = new List<UserEntity>();

for (int i = 0; i < rowsCount; i++)
{
users.Add(new UserEntity());
}

var stopwatch = Stopwatch.StartNew();
dbContext.BulkInsert(users);
stopwatch.Stop();

return new BulkBenchmarkResponse(BenchmarkMethod.ExternalBulkInsert, rowsCount,
stopwatch.ElapsedMilliseconds.ToString());
}

private async Task ResetDbAsync(bool ignore)
{
if (ignore)
Expand Down
4 changes: 2 additions & 2 deletions test/PandaNuGet.Demo/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Error",
"Microsoft.AspNetCore": "Error"
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
Expand Down

0 comments on commit ecaf089

Please sign in to comment.