Neuerstellung

- Quelle: https://github.com/oxyplot/oxyplot
This commit is contained in:
2023-09-02 09:24:59 +02:00
commit 9520c1fa4a
810 changed files with 117869 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@@ -0,0 +1,103 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EmptyRenderContext.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Provides an empty <see cref="IRenderContext" /> that does nothing.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace PerformanceTest
{
using System.Collections.Generic;
using OxyPlot;
/// <summary>
/// Provides an empty <see cref="IRenderContext" /> that does nothing.
/// </summary>
public class EmptyRenderContext : IRenderContext
{
/// <inheritdoc/>
public bool RendersToScreen { get; set; } = true;
/// <inheritdoc/>
public void CleanUp()
{
}
/// <inheritdoc/>
public void DrawEllipse(OxyRect extents, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode)
{
}
/// <inheritdoc/>
public void DrawEllipses(IList<OxyRect> extents, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode)
{
}
/// <inheritdoc/>
public void DrawImage(OxyImage source, double srcX, double srcY, double srcWidth, double srcHeight, double destX, double destY, double destWidth, double destHeight, double opacity, bool interpolate)
{
}
/// <inheritdoc/>
public void PushClip(OxyRect clippingRectangle)
{
}
/// <inheritdoc/>
public void PopClip()
{
}
/// <inheritdoc/>
public int ClipCount => 0;
/// <inheritdoc/>
public void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray = null, LineJoin lineJoin = LineJoin.Miter)
{
}
/// <inheritdoc/>
public void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray = null, LineJoin lineJoin = LineJoin.Miter)
{
}
/// <inheritdoc/>
public void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray = null, LineJoin lineJoin = LineJoin.Miter)
{
}
/// <inheritdoc/>
public void DrawPolygons(IList<IList<ScreenPoint>> polygons, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray = null, LineJoin lineJoin = LineJoin.Miter)
{
}
/// <inheritdoc/>
public void DrawRectangle(OxyRect rectangle, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode)
{
}
/// <inheritdoc/>
public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode)
{
}
/// <inheritdoc/>
public void DrawText(ScreenPoint p, string text, OxyColor fill, string fontFamily = null, double fontSize = 10, double fontWeight = 400, double rotation = 0, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left, VerticalAlignment verticalAlignment = VerticalAlignment.Top, OxySize? maxSize = null)
{
}
/// <inheritdoc/>
public OxySize MeasureText(string text, string fontFamily = null, double fontSize = 10, double fontWeight = 500)
{
return OxySize.Empty;
}
/// <inheritdoc/>
public void SetToolTip(string text)
{
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0-windows;net7.0-windows</TargetFrameworks>
<OutputType>Exe</OutputType>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\OxyPlot\OxyPlot.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,148 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Program.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// A performance test program.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace PerformanceTest
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using OxyPlot;
using OxyPlot.Series;
/// <summary>
/// A performance test program.
/// </summary>
/// <remarks>
/// Build with the Release configuration.
/// To be used with a profiler or as a standalone program (remember to run outside the Visual Studio IDE).
/// </remarks>
public class Program
{
/// <summary>
/// The program entry point.
/// </summary>
public static void Main()
{
var testModels = new Dictionary<string, PlotModel>
{
{ "LineSeries with 100000 points", CreateModel(100000) },
{ "LineSeries with 100000 points in ItemsSource", CreateModel2(100000) }
};
foreach (var kvp in testModels)
{
Console.WriteLine(kvp.Key);
TestModelUpdate(kvp.Value);
TestModelRender(kvp.Value);
Console.WriteLine();
}
Console.WriteLine("DrawReducedLine test:");
var t0 = TestDrawReducedLine(10000, 1000, false);
var t1 = TestDrawReducedLine(10000, 1000, true);
Console.WriteLine("{0:P1}", (t0 - t1) / t0);
Console.ReadKey();
}
public static double TestModelUpdate(PlotModel model, int m = 1000)
{
var stopwatch = Stopwatch.StartNew();
for (int i = 0; i < m; i++)
{
((IPlotModel)model).Update(true);
}
stopwatch.Stop();
Console.WriteLine("Update: {0}", (double)stopwatch.ElapsedMilliseconds);
return stopwatch.ElapsedMilliseconds;
}
public static double TestModelRender(PlotModel model, int m = 100)
{
var rc = new EmptyRenderContext();
var stopwatch = Stopwatch.StartNew();
for (int i = 0; i < m; i++)
{
((IPlotModel)model).Render(rc, new OxyRect(0, 0, 800, 600));
}
stopwatch.Stop();
Console.WriteLine("Render: {0}", (double)stopwatch.ElapsedMilliseconds);
return stopwatch.ElapsedMilliseconds;
}
private static PlotModel CreateModel(int n)
{
var model = new PlotModel();
var series = new LineSeries();
for (int i = 0; i < n; i++)
{
series.Points.Add(new DataPoint(i, Math.Sin(i)));
}
model.Series.Add(series);
((IPlotModel)model).Update(true);
return model;
}
private static PlotModel CreateModel2(int n)
{
var points = new List<DataPoint>();
for (int i = 0; i < n; i++)
{
points.Add(new DataPoint(i, Math.Sin(i)));
}
var model = new PlotModel();
var series = new LineSeries();
series.ItemsSource = points;
model.Series.Add(series);
((IPlotModel)model).Update(true);
return model;
}
/// <summary>
/// Tests the <see cref="RenderingExtensions.DrawReducedLine" /> method.
/// </summary>
/// <param name="n">The number of points.</param>
/// <param name="m">The number of repetitions.</param>
/// <param name="useOutputBuffer"><c>true</c> to use an output buffer.</param>
/// <returns>The elapsed time in milliseconds.</returns>
public static double TestDrawReducedLine(int n, int m, bool useOutputBuffer)
{
var points = new ScreenPoint[n];
for (int i = 0; i < n; i++)
{
points[i] = new ScreenPoint((double)i / n, Math.Sin(40d * i / n));
}
var rc = new EmptyRenderContext();
var outputBuffer = useOutputBuffer ? new List<ScreenPoint>(n) : null;
var stopwatch = Stopwatch.StartNew();
for (int i = 0; i < m; i++)
{
rc.DrawReducedLine(
points,
1,
OxyColors.Black,
1,
EdgeRenderingMode.Automatic,
null,
LineJoin.Miter,
outputBuffer);
}
stopwatch.Stop();
Console.WriteLine((double)stopwatch.ElapsedMilliseconds);
return stopwatch.ElapsedMilliseconds;
}
}
}