Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port System.Drawing benchmarks from CoreFX #350

Merged
merged 5 commits into from
Mar 2, 2019

Conversation

adamsitnik
Copy link
Member

No description provided.

@adamsitnik
Copy link
Member Author

Part of #344

@adamsitnik
Copy link
Member Author

adamsitnik commented Mar 1, 2019

@JeremyKuhne @ViktorHofer could you please take a look? this is a port from xunit-performance to BenchmarkDotNet, git blame tells me that you are the most familiar people with these benchmarks :D

You can ignore the failed ARM build, it's due to #333

@@ -61,4 +62,8 @@
<Compile Remove="corefx\System.Security.Cryptography\Perf.Rfc2898DeriveBytes.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the API is not available for .NET Core 2.0


static Perf_Color()
{
AllKnownColors = new[]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original benchmark was using reflection to read that https://github.com/dotnet/corefx/blob/9940166bff52155600f25f15da13a83c982526d2/src/System.Drawing.Primitives/tests/Performance/Perf_Color.cs#L18-L22

I want to add CoreRT runs soon, so I did remove the reflection. There is also a chance (very small ofc) that in the future we might add new colors to System.Drawing.Color which would be simply seen as a regression (the array would grow and the time as well)

_point3 = new Point(35, 5);
_point4 = new Point(50, 10);

_points = new[] {_point1, _point2, _point3, _point4};
Copy link
Member Author

@adamsitnik adamsitnik Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old benchmarks were using 4 random points for DrawBezier_Point and array of 7 different points for DrawBezier_Points

https://github.com/dotnet/corefx/blob/9940166bff52155600f25f15da13a83c982526d2/src/System.Drawing.Common/tests/Performance/Perf_Graphics_DrawBeziers.cs#L42

I unified that to make sure that we compare apples to apples (same points)

new ImageTestData(ImageFormat.Jpeg),
new ImageTestData(ImageFormat.Png),
new ImageTestData(ImageFormat.Gif)
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graphics.DrawBezier(pen, RandomPoint(), RandomPoint(), RandomPoint(), RandomPoint());
}

bitmap.Save(result, format);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old benchmarks were writing to file

https://github.com/dotnet/corefx/blob/9940166bff52155600f25f15da13a83c982526d2/src/System.Drawing.Common/tests/Performance/Perf_Image_Load.cs#L144

to avoid multimodality of the benchmarks (possibly introduced by disk IO) I decided to use MemoryStream instead.

}

[Benchmark]
[AllowedOperatingSystems("Graphics.TransformPoints is not implemented in libgdiplus yet. See dotnet/corefx 20884", OS.Windows)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only benchmark that can't run on the OSes that we test (Windows RS4, Ubuntu 16.04)

there were some other conditional benchmarks that would not run for Ubuntu 14.04 and other Unixes but we don't test those OSes in our lab so I did not port those conditions

@adamsitnik adamsitnik merged commit dfc3d9b into dotnet:master Mar 2, 2019
@adamsitnik adamsitnik deleted the systemDrawing branch March 2, 2019 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants