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

Allow for Config per method, introduce OS and OSArchitecture filters #1097

Merged
merged 15 commits into from
Feb 8, 2021

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Mar 10, 2019

in the dotnet/performance repo, I need to enable/disable some benchmarks per OS/architecture/something else like AVX2.IsAvailable. As of today, we allow to enable the configs per entire type, so if I want to disable one benchmark out of N for Linux, I have to move it to a dedicated type and apply some config to it via attributes. This is not very user friendly.

My proposal: allow for configs per methods.

I have changed how BenchmarkConverter works and now it looks for the method attributes as well.

What is very important, I did not change AttributeTargets flags for any of our Attributes except of FilterConfigBaseAttribute and JobMutatorConfigBaseAttribute so basically this feature currently works only for Filter and Job attributes.

@AndreyAkinshin what do you think?

/cc @ig-sinicyn

: base(new SimpleFilter(_ =>
{
return allowed
? platforms.Any(platform => RuntimeInformation.IsOSPlatform(Map(platform)))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could take the string of a OSPlatform instead of PlatformID? (basically the string that gets passed into https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform.create)

I don't think PlatformID is going to work.

From https://docs.microsoft.com/en-us/dotnet/api/system.platformid

MacOSX | 6 | The operating system is Macintosh. This value was returned by Silverlight. On .NET Core, its replacement is Unix.

From that, it sounds like you won't be able to distinguish between macOS and Linux on .NET Core using PlatformID.

Copy link
Member Author

Choose a reason for hiding this comment

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

@eerhardt I am not sure about string. For example: let's say that I dont't want to run the benchmark on Ubuntu. Should I put Unix? Linux? or Ubuntu? or Ubuntu16.04?

But I agree that PlatformID is not perfect, I had to implement a mapping on my own.

Maybe I should just introduce a new enum?

Copy link
Member

Choose a reason for hiding this comment

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

Should I put Unix? Linux? or Ubuntu? or Ubuntu16.04?

Do you want that deep of control? Do you want to be able to say "All Unixes" vs. "just Ubuntu, but not RedHat or OpenSUSE"? If so, it seems like a perfect place to use RIDs...

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want that deep of control?

No, I just wanted to show that without an enum, the user needs to guess the right string value.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's been two years since I created this PR, but now I really need tha for Randomization in the perf repo so I've updated it. I decided to include my own simple enum, just so users don't have to type OS names manually (an avoid mistakes for "OSX" != "macOS" etc)

Copy link
Member

@AndreyAkinshin AndreyAkinshin left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsitnik adamsitnik added this to the v0.13.0 milestone Feb 8, 2021
@adamsitnik adamsitnik merged commit d758f63 into master Feb 8, 2021
@adamsitnik adamsitnik deleted the configPerMethod branch February 8, 2021 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants