First Commit
This commit is contained in:
parent
bb40883c7d
commit
696158848f
18 changed files with 787 additions and 0 deletions
106
StitchATon.Bench/Program.cs
Normal file
106
StitchATon.Bench/Program.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
using System.Diagnostics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using OpenCvSharp;
|
||||
using StitchATon.Services;
|
||||
|
||||
namespace StitchATon.Bench;
|
||||
|
||||
public class Program
|
||||
{
|
||||
static readonly ImageProvider Ip = new ( new ImageProvider.Config(
|
||||
"/home/retorikal/Downloads/tiles1705/",
|
||||
720,
|
||||
55,
|
||||
31),
|
||||
NullLogger<ImageProvider>.Instance );
|
||||
// static ImageProvider ip = new ( "/mnt/ramdisk/" );
|
||||
|
||||
static async Task Fn1()
|
||||
{
|
||||
using var im = await Ip.GetImage(
|
||||
new Rect( new Point( 0, 0 ), new Size( 2, 1 ) ),
|
||||
new Point2f( 0, 0 ),
|
||||
new Point2f( 1, 1 ) );
|
||||
// Cv2.ImEncode(".png", im, out _);
|
||||
Cv2.ImWrite("/tmp/im1.png", im );
|
||||
}
|
||||
|
||||
static async Task Fn2()
|
||||
{
|
||||
using var im = await Ip.GetImage(
|
||||
new Rect( new Point( 1, 1 ), new Size( 3, 3 ) ),
|
||||
new Point2f( 0, 0 ),
|
||||
new Point2f( 1, 1 ) );
|
||||
// Cv2.ImEncode(".png", im, out _);
|
||||
// Cv2.ImWrite("/tmp/im2.png", im2 );
|
||||
}
|
||||
|
||||
static async Task Fn3()
|
||||
{
|
||||
using var im = await Ip.GetImage(
|
||||
new Rect( new Point( 2, 2 ), new Size( 3, 3 ) ),
|
||||
new Point2f( 0.2f, 0.2f ),
|
||||
new Point2f( .6f, .6f ) );
|
||||
// Cv2.ImEncode(".png", im, out _);
|
||||
// Cv2.ImWrite("/tmp/im3.png", im3 );
|
||||
}
|
||||
|
||||
static async Task Fn4()
|
||||
{
|
||||
using var im = await Ip.GetImage(
|
||||
new Rect( new Point( 0, 0 ), new Size( 10, 10 ) ),
|
||||
new Point2f( 0.2f, 0.2f ),
|
||||
new Point2f( .6f, .6f ) );
|
||||
// Cv2.ImEncode(".png", im, out _);
|
||||
// Cv2.ImWrite("/tmp/im4.png", im4 );
|
||||
}
|
||||
|
||||
|
||||
// [Benchmark]
|
||||
static async Task Conc()
|
||||
{
|
||||
await Task.WhenAll(
|
||||
Fn1(),
|
||||
Fn2(),
|
||||
Fn3(),
|
||||
Fn4()
|
||||
);
|
||||
}
|
||||
|
||||
// [Benchmark]
|
||||
static async Task Serial()
|
||||
{
|
||||
await Fn1();
|
||||
await Fn2();
|
||||
await Fn3();
|
||||
await Fn4();
|
||||
}
|
||||
|
||||
public static ProcessStartInfo MkfifoPs = new("mkfifo", "/tmp/out.png");
|
||||
public static ProcessStartInfo RmfifoPs = new("rm", "/tmp/out.png");
|
||||
|
||||
[Benchmark]
|
||||
public void Mkfifo()
|
||||
{
|
||||
Process.Start( MkfifoPs )?.WaitForExit();
|
||||
Process.Start( RmfifoPs )?.WaitForExit();
|
||||
}
|
||||
|
||||
public async static Task Main( string[] args )
|
||||
{
|
||||
|
||||
await Fn1();
|
||||
// var summary = BenchmarkRunner.Run<Program>();
|
||||
// var stopwatch = Stopwatch.StartNew();
|
||||
//
|
||||
//
|
||||
// stopwatch.Stop();
|
||||
// Console.WriteLine( $"Elapsed time: {stopwatch.ElapsedMilliseconds} ms" );
|
||||
//
|
||||
// var stopwatchAfter = Stopwatch.StartNew();
|
||||
// await Fn4();
|
||||
// stopwatchAfter.Stop();
|
||||
// Console.WriteLine( $"Elapsed time: {stopwatchAfter.ElapsedMilliseconds} ms" );
|
||||
}
|
||||
}
|
||||
21
StitchATon.Bench/StitchATon.Bench.csproj
Normal file
21
StitchATon.Bench/StitchATon.Bench.csproj
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>StitchATon.Bench</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.11.0.20250507" />
|
||||
<PackageReference Include="OpenCvSharp4_runtime.debian.12-x64" Version="4.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StitchATon\StitchATon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue