From cdbbcce3bf40bd1ec27d20ec435df36086c41863 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Sun, 22 Dec 2024 21:00:32 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=B0=D1=80=D1=82=D0=B8=D1=86=D0=B8=D0=BE=D0=BD?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20241126071115_Add_ChangeLog.Designer.cs | 2 +- .../20241203120141_ParameterDataMigration.cs | 35 ------ ...212041758_TechMessageMigration.Designer.cs | 24 ---- ...112828_ParameterDataMigration.Designer.cs} | 102 +++++++++++++---- .../20241222112828_ParameterDataMigration.cs | 61 +++++++++++ ...PersistencePostgresContextModelSnapshot.cs | 9 +- .../{ => ParameterData}/ParameterData.cs | 5 +- .../Entity/ParameterData/ParameterData1.cs | 10 ++ .../Entity/ParameterData/ParameterData10.cs | 10 ++ .../Entity/ParameterData/ParameterData11.cs | 10 ++ .../Entity/ParameterData/ParameterData12.cs | 10 ++ .../Entity/ParameterData/ParameterData13.cs | 10 ++ .../Entity/ParameterData/ParameterData14.cs | 10 ++ .../Entity/ParameterData/ParameterData15.cs | 10 ++ .../Entity/ParameterData/ParameterData16.cs | 10 ++ .../Entity/ParameterData/ParameterData17.cs | 10 ++ .../Entity/ParameterData/ParameterData18.cs | 10 ++ .../Entity/ParameterData/ParameterData19.cs | 10 ++ .../Entity/ParameterData/ParameterData2.cs | 10 ++ .../Entity/ParameterData/ParameterData20.cs | 10 ++ .../Entity/ParameterData/ParameterData21.cs | 10 ++ .../Entity/ParameterData/ParameterData22.cs | 10 ++ .../Entity/ParameterData/ParameterData23.cs | 10 ++ .../Entity/ParameterData/ParameterData24.cs | 10 ++ .../Entity/ParameterData/ParameterData25.cs | 10 ++ .../Entity/ParameterData/ParameterData3.cs | 10 ++ .../Entity/ParameterData/ParameterData4.cs | 10 ++ .../Entity/ParameterData/ParameterData5.cs | 10 ++ .../Entity/ParameterData/ParameterData6.cs | 10 ++ .../Entity/ParameterData/ParameterData7.cs | 10 ++ .../Entity/ParameterData/ParameterData8.cs | 10 ++ .../Entity/ParameterData/ParameterData9.cs | 10 ++ .../PersistenceDbContext.cs | 29 ++++- .../UsefulQueries/create_partitions.sql | 12 ++ .../partition_insert_function.sql | 1 + .../partition_insert_trigger.sql | 12 ++ .../Controllers/WitsDataControllerTest.cs | 2 +- .../Repositories/ParameterRepository.cs | 103 +++++++++++++++++- .../Database/DbConnection.cs | 2 +- .../Tests/WitsDataBenchmark.cs | 77 +++++++------ Persistence.Benchmark/WebAppFactoryFixture.cs | 2 +- 41 files changed, 599 insertions(+), 129 deletions(-) delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs rename DD.Persistence.Database.Postgres/Migrations/{20241203120141_ParameterDataMigration.Designer.cs => 20241222112828_ParameterDataMigration.Designer.cs} (73%) create mode 100644 DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs rename DD.Persistence.Database/Entity/{ => ParameterData}/ParameterData.cs (84%) create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData1.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData10.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData11.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData12.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData13.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData14.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData15.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData16.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData17.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData18.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData19.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData2.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData20.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData21.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData22.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData23.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData24.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData25.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData3.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData4.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData5.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData6.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData7.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData8.cs create mode 100644 DD.Persistence.Database/Entity/ParameterData/ParameterData9.cs create mode 100644 DD.Persistence.Database/UsefulQueries/create_partitions.sql create mode 100644 DD.Persistence.Database/UsefulQueries/partition_insert_function.sql create mode 100644 DD.Persistence.Database/UsefulQueries/partition_insert_trigger.sql diff --git a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs index 7fa7567..f1867f0 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs @@ -12,7 +12,7 @@ using DD.Persistence.Database.Model; namespace DD.Persistence.Database.Postgres.Migrations { - [DbContext(typeof(PersistenceDbContext))] + [DbContext(typeof(PersistencePostgresContext))] [Migration("20241126071115_Add_ChangeLog")] partial class Add_ChangeLog { diff --git a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs deleted file mode 100644 index 830f5b9..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - /// - 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 параметра"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), - Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") - }, - constraints: table => - { - table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp }); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ParameterData"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs index 1e28de3..6ec1746 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs @@ -48,30 +48,6 @@ namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("DrillingSystem"); }); - 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("Value") - .IsRequired() - .HasColumnType("varchar(256)") - .HasComment("Значение параметра в виде строки"); - - b.HasKey("DiscriminatorId", "ParameterId", "Timestamp"); - - b.ToTable("ParameterData"); - }); - modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { b.Property("EventId") diff --git a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.Designer.cs similarity index 73% rename from DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs rename to DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.Designer.cs index 2afaaa3..93c602e 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.Designer.cs @@ -1,18 +1,18 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; #nullable disable -namespace DD.Persistence.Database.Postgres.Migrations +namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres { - [DbContext(typeof(PersistenceDbContext))] - [Migration("20241203120141_ParameterDataMigration")] + [DbContext(typeof(PersistencePostgresContext))] + [Migration("20241222112828_ParameterDataMigration")] partial class ParameterDataMigration { /// @@ -27,38 +27,43 @@ namespace DD.Persistence.Database.Postgres.Migrations NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("DD.Persistence.Database.Entity.DrillingSystem", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b => { b.Property("SystemId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasComment("Id системы автобурения"); + .HasComment("Id системы - источника данных"); b.Property("Description") .HasColumnType("text") - .HasComment("Описание системы автобурения"); + .HasComment("Описание системы - источника данных"); b.Property("Name") .IsRequired() .HasColumnType("varchar(256)") - .HasComment("Наименование системы автобурения"); + .HasComment("Наименование системы - источника данных"); b.HasKey("SystemId"); - b.ToTable("DrillingSystem"); + b.ToTable("DataSourceSystem"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => { - b.Property("DiscriminatorId") - .HasColumnType("integer") + b.Property("DiscriminatorId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") .HasComment("Дискриминатор системы"); b.Property("ParameterId") + .ValueGeneratedOnAdd() .HasColumnType("integer") .HasComment("Id параметра"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ParameterId")); + b.Property("Timestamp") + .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasComment("Временная отметка"); @@ -83,27 +88,23 @@ namespace DD.Persistence.Database.Postgres.Migrations .HasColumnType("integer") .HasComment("Id Категории важности"); - b.Property("Depth") - .HasColumnType("double precision") - .HasComment("Глубина забоя"); + b.Property("EventState") + .HasColumnType("integer") + .HasComment("Статус события"); - b.Property("MessageText") + b.Property("SystemId") + .HasColumnType("uuid") + .HasComment("Id системы, к которой относится сообщение"); + + b.Property("Text") .IsRequired() .HasColumnType("varchar(512)") .HasComment("Текст сообщения"); - b.Property("SystemId") - .HasColumnType("uuid") - .HasComment("Id системы автобурения, к которой относится сообщение"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone") .HasComment("Дата возникновения"); - b.Property("UserId") - .HasColumnType("uuid") - .HasComment("Id пользователя за пультом бурильщика"); - b.HasKey("EventId"); b.HasIndex("SystemId"); @@ -134,6 +135,59 @@ namespace DD.Persistence.Database.Postgres.Migrations }); }); + modelBuilder.Entity("DD.Persistence.Database.Model.ChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("Ключ записи"); + + b.Property("Creation") + .HasColumnType("timestamp with time zone") + .HasComment("Дата создания записи"); + + b.Property("DepthEnd") + .HasColumnType("double precision") + .HasComment("Глубина забоя на дату окончания интервала"); + + b.Property("DepthStart") + .HasColumnType("double precision") + .HasComment("Глубина забоя на дату начала интервала"); + + b.Property("IdAuthor") + .HasColumnType("uuid") + .HasComment("Автор изменения"); + + b.Property("IdDiscriminator") + .HasColumnType("uuid") + .HasComment("Дискриминатор таблицы"); + + b.Property("IdEditor") + .HasColumnType("uuid") + .HasComment("Редактор"); + + b.Property("IdNext") + .HasColumnType("uuid") + .HasComment("Id заменяющей записи"); + + b.Property("IdSection") + .HasColumnType("uuid") + .HasComment("Ключ секции"); + + b.Property("Obsolete") + .HasColumnType("timestamp with time zone") + .HasComment("Дата устаревания (например при удалении)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("jsonb") + .HasComment("Значение"); + + b.HasKey("Id"); + + b.ToTable("ChangeLog"); + }); + modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => { b.Property("Date") @@ -243,7 +297,7 @@ namespace DD.Persistence.Database.Postgres.Migrations modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { - b.HasOne("DD.Persistence.Database.Entity.DrillingSystem", "System") + b.HasOne("DD.Persistence.Database.Entity.DataSourceSystem", "System") .WithMany() .HasForeignKey("SystemId") .OnDelete(DeleteBehavior.Cascade) diff --git a/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs new file mode 100644 index 0000000..cb08b16 --- /dev/null +++ b/DD.Persistence.Database.Postgres/Migrations/20241222112828_ParameterDataMigration.cs @@ -0,0 +1,61 @@ +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/PersistencePostgresContextModelSnapshot.cs b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs index a475f75..33258f7 100644 --- a/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs +++ b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs @@ -1,10 +1,10 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; #nullable disable @@ -48,19 +48,23 @@ namespace DD.Persistence.Database.Postgres.Migrations modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => { b.Property("DiscriminatorId") + .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasComment("Дискриминатор системы"); b.Property("ParameterId") + .ValueGeneratedOnAdd() .HasColumnType("integer") .HasComment("Id параметра"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ParameterId")); + b.Property("Timestamp") + .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasComment("Временная отметка"); b.Property("Value") - .IsRequired() .HasColumnType("varchar(256)") .HasComment("Значение параметра в виде строки"); @@ -69,6 +73,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.ToTable("ParameterData"); }); + modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { b.Property("EventId") diff --git a/DD.Persistence.Database/Entity/ParameterData.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData.cs similarity index 84% rename from DD.Persistence.Database/Entity/ParameterData.cs rename to DD.Persistence.Database/Entity/ParameterData/ParameterData.cs index c81b029..5ffce59 100644 --- a/DD.Persistence.Database/Entity/ParameterData.cs +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData.cs @@ -2,8 +2,9 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace DD.Persistence.Database.Entity; +namespace DD.Persistence.Database.Entity.ParameterData; +[Table("ParameterData")] [PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))] public class ParameterData { @@ -14,7 +15,7 @@ public class ParameterData public int ParameterId { get; set; } [Column(TypeName = "varchar(256)"), Comment("Значение параметра в виде строки")] - public required string Value { get; set; } + public string Value { get; set; } [Comment("Временная отметка")] public DateTimeOffset Timestamp { get; set; } diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData1.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData1.cs new file mode 100644 index 0000000..c918c58 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData1.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData1")] +public class ParameterData1 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData10.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData10.cs new file mode 100644 index 0000000..7a6e757 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData10.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData10")] +public class ParameterData10 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData11.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData11.cs new file mode 100644 index 0000000..ea4d567 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData11.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData11")] +public class ParameterData11 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData12.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData12.cs new file mode 100644 index 0000000..f27fa57 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData12.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData12")] +public class ParameterData12 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData13.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData13.cs new file mode 100644 index 0000000..de39497 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData13.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData13")] +public class ParameterData13 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData14.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData14.cs new file mode 100644 index 0000000..3588884 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData14.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData14")] +public class ParameterData14 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData15.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData15.cs new file mode 100644 index 0000000..7f7d96e --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData15.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData15")] +public class ParameterData15 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData16.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData16.cs new file mode 100644 index 0000000..8e3350a --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData16.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData16")] +public class ParameterData16 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData17.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData17.cs new file mode 100644 index 0000000..01759ba --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData17.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData17")] +public class ParameterData17 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData18.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData18.cs new file mode 100644 index 0000000..6da79b3 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData18.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData18")] +public class ParameterData18 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData19.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData19.cs new file mode 100644 index 0000000..5caa9c4 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData19.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData19")] +public class ParameterData19 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData2.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData2.cs new file mode 100644 index 0000000..d698caf --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData2.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData2")] +public class ParameterData2 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData20.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData20.cs new file mode 100644 index 0000000..569d166 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData20.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData20")] +public class ParameterData20 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData21.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData21.cs new file mode 100644 index 0000000..61a21e2 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData21.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData21")] +public class ParameterData21 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData22.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData22.cs new file mode 100644 index 0000000..b0b74f3 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData22.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData22")] +public class ParameterData22 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData23.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData23.cs new file mode 100644 index 0000000..1f26b2c --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData23.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData23")] +public class ParameterData23 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData24.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData24.cs new file mode 100644 index 0000000..514b93f --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData24.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData24")] +public class ParameterData24 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData25.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData25.cs new file mode 100644 index 0000000..47e873f --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData25.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData25")] +public class ParameterData25 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData3.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData3.cs new file mode 100644 index 0000000..4014e84 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData3.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData3")] +public class ParameterData3 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData4.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData4.cs new file mode 100644 index 0000000..8d0afc1 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData4.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData4")] +public class ParameterData4 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData5.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData5.cs new file mode 100644 index 0000000..7647875 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData5.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData5")] +public class ParameterData5 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData6.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData6.cs new file mode 100644 index 0000000..7bcccb0 --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData6.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData6")] +public class ParameterData6 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData7.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData7.cs new file mode 100644 index 0000000..c007f8e --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData7.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData7")] +public class ParameterData7 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData8.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData8.cs new file mode 100644 index 0000000..c022f8a --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData8.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData8")] +public class ParameterData8 : ParameterData +{ +} diff --git a/DD.Persistence.Database/Entity/ParameterData/ParameterData9.cs b/DD.Persistence.Database/Entity/ParameterData/ParameterData9.cs new file mode 100644 index 0000000..842d83b --- /dev/null +++ b/DD.Persistence.Database/Entity/ParameterData/ParameterData9.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DD.Persistence.Database.Entity.ParameterData; + +[Table("ParameterData9")] +public class ParameterData9 : ParameterData +{ +} diff --git a/DD.Persistence.Database/PersistenceDbContext.cs b/DD.Persistence.Database/PersistenceDbContext.cs index a0587cd..0fe7a72 100644 --- a/DD.Persistence.Database/PersistenceDbContext.cs +++ b/DD.Persistence.Database/PersistenceDbContext.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using DD.Persistence.Database.Entity; using DD.Persistence.Database.Model; +using DD.Persistence.Database.Entity.ParameterData; namespace DD.Persistence.Database; @@ -20,8 +21,34 @@ public class PersistenceDbContext : DbContext public DbSet TechMessage => Set(); public DbSet ParameterData => Set(); + public DbSet ParameterData1 => Set(); + public DbSet ParameterData2 => Set(); + public DbSet ParameterData3 => Set(); + public DbSet ParameterData4 => Set(); + public DbSet ParameterData5 => Set(); + public DbSet ParameterData6 => Set(); + public DbSet ParameterData7 => Set(); + public DbSet ParameterData8 => Set(); + public DbSet ParameterData9 => Set(); + public DbSet ParameterData10 => Set(); + public DbSet ParameterData11 => Set(); + public DbSet ParameterData12 => Set(); + public DbSet ParameterData13 => Set(); + public DbSet ParameterData14 => Set(); + public DbSet ParameterData15 => Set(); + public DbSet ParameterData16 => Set(); + public DbSet ParameterData17 => Set(); + public DbSet ParameterData18 => Set(); + public DbSet ParameterData19 => Set(); + public DbSet ParameterData20 => Set(); + public DbSet ParameterData21 => Set(); + public DbSet ParameterData22 => Set(); + public DbSet ParameterData23 => Set(); + public DbSet ParameterData24 => Set(); + public DbSet ParameterData25 => Set(); - public DbSet DataSourceSystem => Set(); + + public DbSet DataSourceSystem => Set(); public PersistenceDbContext(DbContextOptions options) : base(options) diff --git a/DD.Persistence.Database/UsefulQueries/create_partitions.sql b/DD.Persistence.Database/UsefulQueries/create_partitions.sql new file mode 100644 index 0000000..c4ec8d7 --- /dev/null +++ b/DD.Persistence.Database/UsefulQueries/create_partitions.sql @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DD.Persistence.Database.UsefulQueries +{ + class partition_function + { + } +} diff --git a/DD.Persistence.Database/UsefulQueries/partition_insert_function.sql b/DD.Persistence.Database/UsefulQueries/partition_insert_function.sql new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/DD.Persistence.Database/UsefulQueries/partition_insert_function.sql @@ -0,0 +1 @@ + diff --git a/DD.Persistence.Database/UsefulQueries/partition_insert_trigger.sql b/DD.Persistence.Database/UsefulQueries/partition_insert_trigger.sql new file mode 100644 index 0000000..c4ec8d7 --- /dev/null +++ b/DD.Persistence.Database/UsefulQueries/partition_insert_trigger.sql @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DD.Persistence.Database.UsefulQueries +{ + class partition_function + { + } +} diff --git a/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs index f96d21c..739299d 100644 --- a/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.DependencyInjection; -using DD.Persistence.Database.Entity; using DD.Persistence.Models; using System.Net; using Xunit; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client; +using DD.Persistence.Database.Entity.ParameterData; namespace DD.Persistence.IntegrationTests.Controllers; public class WitsDataControllerTest : BaseIntegrationTest diff --git a/DD.Persistence.Repository/Repositories/ParameterRepository.cs b/DD.Persistence.Repository/Repositories/ParameterRepository.cs index 434d59f..3466b92 100644 --- a/DD.Persistence.Repository/Repositories/ParameterRepository.cs +++ b/DD.Persistence.Repository/Repositories/ParameterRepository.cs @@ -1,8 +1,8 @@ using Mapster; using Microsoft.EntityFrameworkCore; -using DD.Persistence.Database.Entity; using DD.Persistence.Models; using DD.Persistence.Repositories; +using DD.Persistence.Database.Entity.ParameterData; namespace DD.Persistence.Repository.Repositories; public class ParameterRepository : IParameterRepository @@ -83,4 +83,105 @@ public class ParameterRepository : IParameterRepository return result; } + + //public async Task AddRange(IEnumerable dtos, CancellationToken token) + //{ + // int result = 0; + + // var groups = dtos.GroupBy(e => e.ParameterId / 1000); + // foreach (var group in groups) + // { + // switch (group.Key) + // { + // case 1: + // result += await AddRange(dtos, token); + // break; + // case 2: + // result += await AddRange(dtos, token); + // break; + // case 3: + // result += await AddRange(dtos, token); + // break; + // case 4: + // result += await AddRange(dtos, token); + // break; + // case 5: + // result += await AddRange(dtos, token); + // break; + // case 6: + // result += await AddRange(dtos, token); + // break; + // case 7: + // result += await AddRange(dtos, token); + // break; + // case 8: + // result += await AddRange(dtos, token); + // break; + // case 9: + // result += await AddRange(dtos, token); + // break; + // case 10: + // result += await AddRange(dtos, token); + // break; + // case 11: + // result += await AddRange(dtos, token); + // break; + // case 12: + // result += await AddRange(dtos, token); + // break; + // case 13: + // result += await AddRange(dtos, token); + // break; + // case 14: + // result += await AddRange(dtos, token); + // break; + // case 15: + // result += await AddRange(dtos, token); + // break; + // case 16: + // result += await AddRange(dtos, token); + // break; + // case 17: + // result += await AddRange(dtos, token); + // break; + // case 18: + // result += await AddRange(dtos, token); + // break; + // case 19: + // result += await AddRange(dtos, token); + // break; + // case 20: + // result += await AddRange(dtos, token); + // break; + // case 21: + // result += await AddRange(dtos, token); + // break; + // case 22: + // result += await AddRange(dtos, token); + // break; + // case 23: + // result += await AddRange(dtos, token); + // break; + // case 24: + // result += await AddRange(dtos, token); + // break; + // case 25: + // result += await AddRange(dtos, token); + // break; + // } + // } + + // return result; + //} + //private async Task AddRange(IEnumerable dtos, CancellationToken token) + // where T : ParameterData + //{ + // var t = dtos.Where(e => e.Value == null); + // var entities = dtos.Select(e => e.Adapt()); + // var tt = entities.Where(e => e.Value == null); + // await db.Set().AddRangeAsync(entities, token); + // var result = await db.SaveChangesAsync(token); + + // return result; + //} } diff --git a/Persistence.Benchmark/Database/DbConnection.cs b/Persistence.Benchmark/Database/DbConnection.cs index 21632f9..cb86625 100644 --- a/Persistence.Benchmark/Database/DbConnection.cs +++ b/Persistence.Benchmark/Database/DbConnection.cs @@ -10,5 +10,5 @@ public class DbConnection public string Password { get; set; } = null!; public string GetConnectionString() => - $"Host={Host};Database={Guid.NewGuid()};Port={Port};Username={Username};Password={Password};Persist Security Info=True;Include Error Detail=True"; + $"Host={Host};Database=persistence;Port={Port};Username={Username};Password={Password};Persist Security Info=True;Include Error Detail=True"; } diff --git a/Persistence.Benchmark/Tests/WitsDataBenchmark.cs b/Persistence.Benchmark/Tests/WitsDataBenchmark.cs index 0c6e18b..4fe42aa 100644 --- a/Persistence.Benchmark/Tests/WitsDataBenchmark.cs +++ b/Persistence.Benchmark/Tests/WitsDataBenchmark.cs @@ -26,50 +26,54 @@ public static class WitsDataBenchmark var sw = new Stopwatch(); - // Create a new bitmap plot surface - var plotSurface = new NPlot.Bitmap.PlotSurface2D(800, 600); + //// Create a new bitmap plot surface + //var plotSurface = new NPlot.Bitmap.PlotSurface2D(800, 600); - // Create a line plot - var linePlot = new LinePlot(); - - var abscissaData = new List() {}; - var ordinateData = new List() {}; + //// Create a line plot + //var linePlot = new LinePlot(); - var saved = 0; - foreach (var item in data) { - var time = sw.Elapsed; - sw.Start(); - var response = await client.AddRange(item, source.Token); - sw.Stop(); + //var abscissaData = new List() { }; + //var ordinateData = new List() { }; - Console.WriteLine($"Сохранено: {response.ToString()}"); - saved = saved + response; - abscissaData.Add(saved/100_000); + //var saved = 0; + //foreach (var item in data) + //{ + // var time = sw.Elapsed; - Console.WriteLine($"Затрачено времени на сохранение части: {sw.Elapsed - time}"); - ordinateData.Add((double)(sw.Elapsed - time).TotalSeconds); - } + // sw.Start(); + // var response = await client.AddRange(item, source.Token); + // sw.Stop(); - Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}"); + // Console.WriteLine($"Сохранено: {response.ToString()}"); + // saved = saved + response; + // abscissaData.Add(saved / 100_000); - // Add the line plot to the plot surface - linePlot.AbscissaData = abscissaData; - linePlot.OrdinateData = ordinateData; - plotSurface.Add(linePlot); + // Console.WriteLine($"Затрачено времени на сохранение части: {sw.Elapsed - time}"); + // ordinateData.Add((double)(sw.Elapsed - time).TotalSeconds); + //} - // Customize the plot (e.g., titles, labels) - plotSurface.Title = "График"; - plotSurface.XAxis1.Label = "Количество сохраненных записей в БД (100.000)"; - plotSurface.YAxis1.Label = "Время на сохранение 100.000 записей (сек.)"; + //Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}"); - // Refresh the plot to render it - plotSurface.Refresh(); - #pragma warning disable - // Save the plot as a PNG image - plotSurface.Bitmap.Save("C:\\Users\\fremo\\source\\repos\\persistence\\Persistence.Benchmark\\plot.png", System.Drawing.Imaging.ImageFormat.Png); - #pragma warning enable + //// Add the line plot to the plot surface + //linePlot.AbscissaData = abscissaData; + //linePlot.OrdinateData = ordinateData; + //plotSurface.Add(linePlot); + + //// Customize the plot (e.g., titles, labels) + //plotSurface.Title = "График"; + //plotSurface.XAxis1.Label = "Количество сохраненных записей в БД (100.000)"; + //plotSurface.YAxis1.Label = "Время на сохранение 100.000 записей (сек.)"; + + //// Refresh the plot to render it + //plotSurface.Refresh(); + + //#pragma warning disable + //// Save the plot as a PNG image + //plotSurface.Bitmap.Save("C:\\Users\\fremo\\source\\repos\\persistence\\Persistence.Benchmark\\plot.png", System.Drawing.Imaging.ImageFormat.Png); + //#pragma warning enable + var dis = Guid.Parse(discriminatorId); var date = DateTime.Now.AddDays(-1); @@ -80,6 +84,7 @@ public static class WitsDataBenchmark sw.Stop(); Console.WriteLine($"Затрачено времени на вычитку: {sw.Elapsed}"); + } catch (Exception ex) { Console.WriteLine(ex.Message); @@ -90,13 +95,13 @@ public static class WitsDataBenchmark { var result = new List>(); - int enumerableCount = countToCreate / 100_000 + (countToCreate % 100_000 == 0 ? 0 : 1); + int enumerableCount = countToCreate / 25_000 + (countToCreate % 25_000 == 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 < 100; i++) + for (var i = 0; i < 25; i++) { var timestamped = DateTimeOffset.UtcNow; var random = new Random(); diff --git a/Persistence.Benchmark/WebAppFactoryFixture.cs b/Persistence.Benchmark/WebAppFactoryFixture.cs index 8741156..683e44b 100644 --- a/Persistence.Benchmark/WebAppFactoryFixture.cs +++ b/Persistence.Benchmark/WebAppFactoryFixture.cs @@ -50,7 +50,7 @@ public class WebAppFactoryFixture : WebApplicationFactory(); - dbContext.Database.EnsureCreatedAndMigrated(); + //dbContext.Database.EnsureCreatedAndMigrated(); dbContext.SaveChanges(); }); }