diff --git a/Persistence.Benchmark/DD.Persistence.Benchmark.csproj b/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj
similarity index 94%
rename from Persistence.Benchmark/DD.Persistence.Benchmark.csproj
rename to DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj
index 3f154ee..87bb221 100644
--- a/Persistence.Benchmark/DD.Persistence.Benchmark.csproj
+++ b/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj
@@ -9,7 +9,6 @@
-
diff --git a/Persistence.Benchmark/Database/BenchmarkDbContext.cs b/DD.Persistence.Benchmark/Database/BenchmarkDbContext.cs
similarity index 67%
rename from Persistence.Benchmark/Database/BenchmarkDbContext.cs
rename to DD.Persistence.Benchmark/Database/BenchmarkDbContext.cs
index d9a532b..7a0e054 100644
--- a/Persistence.Benchmark/Database/BenchmarkDbContext.cs
+++ b/DD.Persistence.Benchmark/Database/BenchmarkDbContext.cs
@@ -1,11 +1,11 @@
using Microsoft.EntityFrameworkCore;
-using Persistence.Benchmark.Database.Entities;
using DD.Persistence.Database;
+using DD.Persistence.Database.Entity;
namespace Persistence.Benchmark.Database;
public class BenchmarkDbContext : PersistenceDbContext
{
- public new DbSet ParameterData => Set();
+ public DbSet ParameterData => Set();
public BenchmarkDbContext(DbContextOptions options) : base(options)
{
}
diff --git a/Persistence.Benchmark/Database/DbConnection.cs b/DD.Persistence.Benchmark/Database/DbConnection.cs
similarity index 100%
rename from Persistence.Benchmark/Database/DbConnection.cs
rename to DD.Persistence.Benchmark/Database/DbConnection.cs
diff --git a/Persistence.Benchmark/Program.cs b/DD.Persistence.Benchmark/Program.cs
similarity index 54%
rename from Persistence.Benchmark/Program.cs
rename to DD.Persistence.Benchmark/Program.cs
index a9285c2..a3cfef2 100644
--- a/Persistence.Benchmark/Program.cs
+++ b/DD.Persistence.Benchmark/Program.cs
@@ -1,8 +1,4 @@
-using BenchmarkDotNet.Running;
-using Persistence.Benchmark;
-using Persistence.Benchmark.Tests;
-using DD.Persistence.API;
-using System.Runtime.InteropServices;
+using Persistence.Benchmark.Tests;
public class Program
{
diff --git a/Persistence.Benchmark/TestHttpClientFactory.cs b/DD.Persistence.Benchmark/TestHttpClientFactory.cs
similarity index 100%
rename from Persistence.Benchmark/TestHttpClientFactory.cs
rename to DD.Persistence.Benchmark/TestHttpClientFactory.cs
diff --git a/Persistence.Benchmark/Tests/WitsDataBenchmark.cs b/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs
similarity index 77%
rename from Persistence.Benchmark/Tests/WitsDataBenchmark.cs
rename to DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs
index 0b2ecb7..7e5d936 100644
--- a/Persistence.Benchmark/Tests/WitsDataBenchmark.cs
+++ b/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs
@@ -8,6 +8,7 @@ namespace Persistence.Benchmark.Tests;
public static class WitsDataBenchmark
{
private const string discriminatorId = "fef21bfd-e924-473d-b6c8-e4377e38245d";
+ private const int chunkSize = 25_000;
public static async Task ExecuteTest(int count)
{
@@ -24,11 +25,6 @@ public static class WitsDataBenchmark
var data = GenerateData(count);
var sw = new Stopwatch();
-
-
- var abscissaData = new List() { };
- var ordinateData = new List() { };
-
var saved = 0;
foreach (var item in data)
{
@@ -37,23 +33,20 @@ public static class WitsDataBenchmark
sw.Start();
var response = await client.AddRange(item, source.Token);
sw.Stop();
-
- Console.WriteLine($"Сохранено: {response.ToString()}");
saved = saved + response;
- abscissaData.Add(saved / 100_000);
-
- Console.WriteLine($"Затрачено времени на сохранение части: {sw.Elapsed - time}");
- ordinateData.Add((double)(sw.Elapsed - time).TotalSeconds);
+ Console.WriteLine($"Сохранено: {saved.ToString()}");
}
Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}");
- var dis = Guid.Parse(discriminatorId);
+ var discriminator = Guid.Parse(discriminatorId);
var date = DateTime.Now.AddDays(-1);
+ Console.WriteLine($"\nВычитка...");
+
sw = new Stopwatch();
sw.Start();
- var get = await client.GetPart(dis, date, count, source.Token);
+ var get = await client.GetPart(discriminator, date, count, source.Token);
sw.Stop();
Console.WriteLine($"Затрачено времени на вычитку: {sw.Elapsed}");
@@ -68,16 +61,18 @@ public static class WitsDataBenchmark
{
var result = new List>();
- int enumerableCount = countToCreate / 25_000 + (countToCreate % 25_000 == 0 ? 0 : 1);
+ int enumerableCount = countToCreate / chunkSize + (countToCreate % chunkSize == 0 ? 0 : 1);
for (var k = 0; k < enumerableCount; k++)
{
var dtos = new List();
for (var j = 0; j < 1000; j++)
{
- for (var i = 0; i < 25; i++)
+ for (var i = 0; i < chunkSize / 1000; i++)
{
- var timestamped = DateTimeOffset.UtcNow;
var random = new Random();
+
+ var timestamped = DateTimeOffset.UtcNow.AddSeconds(random.Next(1, 60 * 60 * 24) * -1);
+
dtos.Add(new WitsDataDto()
{
DiscriminatorId = Guid.Parse(discriminatorId),
diff --git a/Persistence.Benchmark/WebAppFactoryFixture.cs b/DD.Persistence.Benchmark/WebAppFactoryFixture.cs
similarity index 100%
rename from Persistence.Benchmark/WebAppFactoryFixture.cs
rename to DD.Persistence.Benchmark/WebAppFactoryFixture.cs
diff --git a/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs
deleted file mode 100644
index cb08b16..0000000
--- a/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres
-{
- ///
- public partial class ParameterDataMigration : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ParameterData",
- columns: table => new
- {
- DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
- ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра")
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
- Value = table.Column(type: "varchar(256)", nullable: true, comment: "Значение параметра в виде строки")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
- });
-
- string sql;
- for (int i = 1; i <= 25; i++)
- {
- sql = $"create table if not exists \"ParameterData{i}\" (like public.\"ParameterData\" including all) inherits (public.\"ParameterData\");";
- migrationBuilder.Sql(sql);
- }
-
- //sql = "create or replace function partition_for_parameter_data() returns trigger as $$ " +
- // "DECLARE " +
- // " v_parition_name text; " +
- // "BEGIN " +
- // " v_parition_name := format( 'ParameterData%s', NEW.\"ParameterId\" / 1000 ); " +
- // " execute 'INSERT INTO public.\"' || v_parition_name || '\" VALUES ( ($1).* )' USING NEW; " +
- // " return NULL; " +
- // "END; " +
- // "$$ language plpgsql;";
- //migrationBuilder.Sql(sql);
-
- //sql = "create or replace trigger partition_parameter_data " +
- // "before insert on public.\"ParameterData\" " +
- // "for each row execute procedure public.partition_for_parameter_data();";
- //migrationBuilder.Sql(sql);
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ParameterData");
- }
- }
-}
diff --git a/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs
similarity index 91%
rename from DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs
rename to DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs
index 19e0ca8..49436f3 100644
--- a/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs
+++ b/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DD.Persistence.Database.Postgres.Migrations
{
[DbContext(typeof(PersistencePostgresContext))]
- [Migration("20241220062251_Init")]
+ [Migration("20241225094516_Init")]
partial class Init
{
///
@@ -20,7 +20,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "8.0.10")
+ .HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -46,6 +46,30 @@ namespace DD.Persistence.Database.Postgres.Migrations
b.ToTable("DataSourceSystem");
});
+ modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
+ {
+ b.Property("DiscriminatorId")
+ .HasColumnType("uuid")
+ .HasComment("Дискриминатор системы");
+
+ b.Property("ParameterId")
+ .HasColumnType("integer")
+ .HasComment("Id параметра");
+
+ b.Property("Timestamp")
+ .HasColumnType("timestamp with time zone")
+ .HasComment("Временная отметка");
+
+ b.Property