Skip to content

Instantly share code, notes, and snippets.

using System.Data.Common;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace PostgresExtensions;
/*

Другие интересные штуки тут: https://t.me/notes_of_programmer

Текущие выполняемые запросы

select pid, user, client_addr, query_start, backend_type, substr(query, 0, 256) as query
from pg_stat_activity
where query_start is not null
  and client_addr is not null;
@DBalashov
DBalashov / count-loc.ps1
Created March 20, 2024 15:04
Run in solution directory (example): powershell -F ..\count-loc.ps1
$extensions = @(".cs", ".vue", ".scss", ".ts")
$exclude = @("\bin\", "\obj\", "\node_modules\", "\.nuxt\", "\.output\")
$path = $args[0]
$files = Get-ChildItem -Recurse -Include ($extensions | % { '*' + $_ }) $path
$statLength = @{}
$statLOC = @{}
$totalLOC = 0;
00:00:37.345 [INF] [178.134.217.58] [8/realme RMX3834] [Request] POST /api/v1/device/7572e67a-b59b-4181-82b1-fa877961c338/healthcheck responded 200 in 15.1 ms
00:04:07.909 [INF] [178.134.217.58] [8/realme RMX3834] [Request] POST /api/v1/device/7572e67a-b59b-4181-82b1-fa877961c338/healthcheck responded 200 in 14.7 ms
00:06:54.079 [INF] [178.134.217.58] [8/realme RMX3834] [Request] POST /api/v1/device/7572e67a-b59b-4181-82b1-fa877961c338/healthcheck responded 200 in 15.8 ms
00:11:57.037 [WRN] [] [] [Device/DeviceHeartbeatDetectorJob] 1 devices => OFF state due timeout (300 seconds)
00:12:39.328 [INF] [178.134.217.58] [8/realme RMX3834] [Request] POST /api/v1/device/7572e67a-b59b-4181-82b1-fa877961c338/healthcheck responded 200 in 14.8 ms
00:14:36.507 [INF] [178.134.217.58] [8/realme RMX3834] [Request] POST /api/v1/device/7572e67a-b59b-4181-82b1-fa877961c338/healthcheck responded 200 in 15.8 ms
00:19:37.029 [WRN] [] [] [Device/DeviceHeartbeatDetectorJob] 1 devices => OFF state due timeout (300 seconds)
00:20:40.
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal;
namespace PostgresExtensions;
// Validating benchmarks:
// ***** BenchmarkRunner: Start *****
// ***** Found 33 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start *****
// start dotnet restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Projects\Test_Benchmarks\Test_Benchmarks\bin\Release\net7.0\1864e80c-9708-420e-bf08-9157be836835
// command took 1,24s and exited with 0
// start dotnet build -c Release --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Projects\Test_Benchmarks\Test_Benchmarks\bin\Release\net7.0\1864e80c-9708-420e-bf08-9157be836835
// command took 3,52s and exited with 0
// ***** Done, took 00:00:04 (4.96 sec) *****
// Found 33 benchmarks:
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
#pragma warning disable CS8618
var summary = BenchmarkRunner.Run<MainTest>();
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
#pragma warning disable CS8618
var summary = BenchmarkRunner.Run<MainTest>();
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
#pragma warning disable CS8618
var summary = BenchmarkRunner.Run<MainTest>();
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
#pragma warning disable CS8618
var summary = BenchmarkRunner.Run<MainTest>();