-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDevTest.axaml.cs
More file actions
96 lines (76 loc) · 2.98 KB
/
Copy pathDevTest.axaml.cs
File metadata and controls
96 lines (76 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Threading;
using Newtonsoft.Json.Linq;
using RestSharp;
using RestSharp.Authenticators.OAuth2;
using SkiaSharp;
namespace Autodraw;
public partial class DevTest : Window
{
public DevTest()
{
InitializeComponent();
TestBenchmarking.Click += (sender, e) => Benchmark();
TestPopup.Click += TestPopup_Click;
GenerateImage.Click += GenerateImage_ClickAsync;
}
private void GenerateImage_ClickAsync(object? sender, RoutedEventArgs e)
{
new MessageBox().ShowMessageBox("Depreciated!","This is depreciated, please use the context menu prompt instead.\nRight click the image box and select AI Generation");
}
private void TestPopup_Click(object? sender, RoutedEventArgs e)
{
new MessageBox().ShowMessageBox("Hi", "Loser");
}
public static unsafe SKBitmap TestImage(int width, int height)
{
SKBitmap returnbtmp = new(width, height);
var srcPtr = (byte*)returnbtmp.GetPixels().ToPointer();
Random rng = new();
for (var row = 0; row < height; row++)
for (var col = 0; col < width; col++)
{
*srcPtr++ = (byte)rng.Next(0, 255);
*srcPtr++ = (byte)rng.Next(0, 255);
*srcPtr++ = (byte)rng.Next(0, 255);
*srcPtr++ = (byte)rng.Next(0, 255);
}
return returnbtmp;
}
private void Benchmark()
{
var sw = Stopwatch.StartNew();
SKBitmap small = new(64, 64);
sw.Restart();
ImageProcessing.Process(small, new ImageProcessing.Filters { Invert = true });
var TimeTookSmall = sw.ElapsedMilliseconds;
BenchmarkResults.Text = "Results:\n64x64: " + TimeTookSmall;
SKBitmap avg = new(384, 384);
sw.Restart();
ImageProcessing.Process(avg, new ImageProcessing.Filters { Invert = true });
var TimeTookAvg = sw.ElapsedMilliseconds;
BenchmarkResults.Text = "Results:\n64x64: " + TimeTookSmall + "\n384x384: " + TimeTookAvg;
SKBitmap med = new(1024, 1024);
sw.Restart();
ImageProcessing.Process(med, new ImageProcessing.Filters { Invert = true });
var TimeTookMed = sw.ElapsedMilliseconds;
BenchmarkResults.Text = "Results:\n64x64: " + TimeTookSmall + "\n384x384: " + TimeTookAvg + "\n1024x1024: " +
TimeTookMed;
SKBitmap large = new(3072, 3072);
sw.Restart();
ImageProcessing.Process(large, new ImageProcessing.Filters { Invert = true });
var TimeTookLarge = sw.ElapsedMilliseconds;
sw.Reset();
BenchmarkResults.Text = "Results:\n64x64: " + TimeTookSmall + "\n384x384: " + TimeTookAvg + "\n1024x1024: " +
TimeTookMed + "\n4096x4096: " + TimeTookLarge;
small.Dispose();
avg.Dispose();
med.Dispose();
large.Dispose();
}
}