@@ -14,9 +14,6 @@ namespace DrawingBackendBenchmark;
1414/// </summary>
1515internal sealed class BenchmarkForm : Form
1616{
17- private const int BenchmarkWidth = 600 ;
18- private const int BenchmarkHeight = 400 ;
19-
2017 private readonly ComboBox backendSelector ;
2118 private readonly NumericUpDown iterationSelector ;
2219 private readonly TextBox statusTextBox ;
@@ -31,7 +28,7 @@ internal sealed class BenchmarkForm : Form
3128 public BenchmarkForm ( )
3229 {
3330 this . Text = "Drawing Backend Benchmark" ;
34- this . ClientSize = new System . Drawing . Size ( 780 , 560 ) ;
31+ this . ClientSize = new System . Drawing . Size ( 1600 , 1200 ) ;
3532 this . StartPosition = FormStartPosition . CenterScreen ;
3633
3734 FlowLayoutPanel toolbar = new ( )
@@ -63,6 +60,7 @@ public BenchmarkForm()
6360 toolbar . Controls . Add ( this . CreateRunButton ( "1k" , 1_000 ) ) ;
6461 toolbar . Controls . Add ( this . CreateRunButton ( "10k" , 10_000 ) ) ;
6562 toolbar . Controls . Add ( this . CreateRunButton ( "100k" , 100_000 ) ) ;
63+ toolbar . Controls . Add ( this . CreateRunButton ( "200k" , 200_000 ) ) ;
6664
6765 this . statusTextBox = new TextBox
6866 {
@@ -80,23 +78,23 @@ public BenchmarkForm()
8078 {
8179 Dock = DockStyle . Fill ,
8280 AutoScroll = true ,
83- BackColor = System . Drawing . Color . FromArgb ( 24 , 36 , 56 ) ,
81+ BackColor = System . Drawing . Color . FromArgb ( 50 , 36 , 56 ) ,
8482 Padding = new Padding ( 12 ) ,
8583 } ;
8684
8785 this . previewBox = new PictureBox
8886 {
87+ Dock = DockStyle . Fill ,
8988 BackColor = System . Drawing . Color . FromArgb ( 24 , 36 , 56 ) ,
90- SizeMode = PictureBoxSizeMode . Normal ,
91- Size = new System . Drawing . Size ( BenchmarkWidth , BenchmarkHeight ) ,
89+ SizeMode = PictureBoxSizeMode . Normal
9290 } ;
9391 this . previewHost . Controls . Add ( this . previewBox ) ;
9492
9593 this . Controls . Add ( this . previewHost ) ;
9694 this . Controls . Add ( this . statusTextBox ) ;
9795 this . Controls . Add ( toolbar ) ;
98- this . Resize += ( _ , _ ) => this . LayoutPreview ( ) ;
9996
97+ // Fake 1x1 SKGLControl to create a GRContext
10098 this . glControl = new SKGLControl
10199 {
102100 Size = new System . Drawing . Size ( 1 , 1 ) ,
@@ -139,7 +137,6 @@ public BenchmarkForm()
139137 this . backendSelector . SelectedIndex = 0 ;
140138 }
141139
142- this . LayoutPreview ( ) ;
143140 this . Shown += ( _ , _ ) => this . backendSelector . Focus ( ) ;
144141 }
145142
@@ -158,6 +155,10 @@ protected override void Dispose(bool disposing)
158155 base . Dispose ( disposing ) ;
159156 }
160157
158+ private int BenchmarkWidth => this . previewBox . Width ;
159+
160+ private int BenchmarkHeight => this . previewBox . Height ;
161+
161162 /// <summary>
162163 /// Creates one toolbar button that runs the benchmark with the requested line count.
163164 /// </summary>
@@ -195,13 +196,14 @@ private void RunBenchmark(int lineCount)
195196
196197 Cursor previousCursor = this . Cursor ;
197198 this . Cursor = Cursors . WaitCursor ;
199+ VisualLine [ ] lines = GenerateLines ( lineCount , this . BenchmarkWidth , this . BenchmarkHeight , rng ) ;
200+
198201 try
199202 {
200203 for ( int i = 0 ; i < iterations ; i ++ )
201204 {
202- VisualLine [ ] lines = GenerateLines ( lineCount , BenchmarkWidth , BenchmarkHeight , rng ) ;
203205 bool capturePreview = i == iterations - 1 ;
204- using BenchmarkRenderResult result = backend . Render ( lines , BenchmarkWidth , BenchmarkHeight , capturePreview ) ;
206+ using BenchmarkRenderResult result = backend . Render ( lines , this . BenchmarkWidth , this . BenchmarkHeight , capturePreview ) ;
205207
206208 samples . Add ( result . RenderMilliseconds ) ;
207209 this . UpdatePreview ( result , capturePreview ) ;
@@ -221,16 +223,6 @@ private void RunBenchmark(int lineCount)
221223 }
222224 }
223225
224- /// <summary>
225- /// Lays out the fixed-size preview surface in the middle of the scroll host.
226- /// </summary>
227- private void LayoutPreview ( )
228- {
229- int x = Math . Max ( this . previewHost . Padding . Left , ( this . previewHost . ClientSize . Width - this . previewBox . Width ) / 2 ) ;
230- int y = Math . Max ( this . previewHost . Padding . Top , ( this . previewHost . ClientSize . Height - this . previewBox . Height ) / 2 ) ;
231- this . previewBox . Location = new System . Drawing . Point ( x , y ) ;
232- }
233-
234226 /// <summary>
235227 /// Replaces the preview image with the final captured frame from the current run.
236228 /// </summary>
0 commit comments