-
-
Notifications
You must be signed in to change notification settings - Fork 963
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
Add "dotnet new" benchmark project template #1044
Conversation
Nice, can I test this template locally on Windows 10 build 18317 x64? |
...lates/BenchmarkDotNet.BenchmarkPorjectTemplate.CSharp/content/.template.config/template.json
Outdated
Show resolved
Hide resolved
@CatGirlsAreLife Yes, you could test this on windows. To do so install the template from the directory location like this:
After that, you can use it as I described already. |
templates/BenchmarkDotNet.BenchmarkPorjectTemplate.CSharp/content/BenchmarkConfig.cs
Outdated
Show resolved
Hide resolved
templates/BenchmarkDotNet.BenchmarkPorjectTemplate.CSharp/content/BenchmarkConfig.cs
Outdated
Show resolved
Hide resolved
...otNet.BenchmarkPorjectTemplate.CSharp/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp.nuspec
Outdated
Show resolved
Hide resolved
@adamsitnik @AndreyAkinshin is there interest in publishing this? @CodeTherapist mind if I add some commits on top of yours in another PR? |
Fix typos. Align accordingly to PR feedback
@Therzok Thanks for helping me out, very appreciated. Added a VB.NET and a F# template as well. Even I'm primarily using C# to get cool things done - I decided to provide them with the exact same capability and behavior as the C# template. After installation: Building them as is: Create the template nuget packages (using nuget 5.x)
Installing the template nuget packages
Using the template
Accordingly, you can use |
I had some issues with the F# template. I sent a PR to your branch to fix them CodeTherapist#1 |
Fix Fsharp template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeTherapist thanks for the pull request and sorry for such a late reply. I was pretty busy during the last several months and didn't have enough time for BenchmarkDotNet.
In general, it looks and works great! It would be awesome to have such templates in the terminal. However, I have several concerns:
- Currently, we have three different NuGet packages with templates which should be installed independently. It will be better to have only one NuGet package to them all. You can use the NUnit 3 Test Project Template as an example.
- It's better to use the current version of BenchmarkDotNet in the csproj file instead of
0.1*
. We didn't release the1.0
version, which allows us to make some breaking changes from time to time (of course, we prefer to make backward compatible releases when it's possible). So, I don't really like the floating NuGet package reference versions because a new release of BenchmarkDotNet can spoil the existing solutions. - Other templates (like
console
,classlib
,xunit
,mvc
) use the--no-restore
option for skipping restore. It would be nice to use the same name to be consistent. - It will be better to reference
BenchmarkDotNet.Diagnostics.Windows
only if a benchmark is created on Windows. - I prefer to use the current BenchmarkDotNet version as a template version (in the nuspec file). It will simplify syncing between templates and new versions of the library.
- Since we don't have proper support of BenchmarkDotNet projects in IDEs (VS, Rider) as we have for unit tests, it will be better to create a
netcoreapp
project by default with the followingMain
method:
class Program
{
static void Main(string[] args)
{
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
It will help developers to easily run benchmarks from an IDE during the benchmark design stage.
No issue, we are all usually busy 👍 Thanks for your answers and your time, reviewing my PR. I agree on all your statements except for number six: I think we should encourage the users to use the awesome dotnet tool (#213) to run the benchmarks quickly - I will add it as optional option. |
@adamsitnik what do you think?
Yeah, it will be great. I already working on the advanced BenchmarkDotNet support in Rider. |
* One nuget package for all templates * No floating version for nuget references * --no-restore instead of skipRestore * `BenchmarkDotNet.Diagnostics.Windows` only on Windows * Sync template version with BenchmarkDotNet version
@AndreyAkinshin Thanks for your review - everything done, except number 6. |
...lates/Content/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
templates/Content/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp/_BenchmarkProjectName_.csproj
Show resolved
Hide resolved
What do you think about "netcoreapp with Main method" as an option? (We can keep the existing behaviour with netstandard/classlib as the default) |
Sure! Also thought about that and mentioned this few comments earlier as well. |
LGTM. Could you please also merge master into your branch and resolve the conflicts? |
# Conflicts: # docs/articles/guides/toc.yml
@CodeTherapist in general, it works great! I will merge the PR as soon as you introduce the |
...lates/Content/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
* --console-app is an optional template parameter to create a console app project. * Minor fixes and better default names. * Updating docs
@AndreyAkinshin: The The templates are not tested at the moment during the build. I think we should do this to ensure further changes do not break the templates. What do you think? |
@CodeTherapist everything works great! Thank you very much for your contribution! |
@CodeTherapist first of all, thanks for the template, very appreciated!
IMO it seems like either more promotion of global tools is required, or default value should be changed. |
After install the template, I create a references: |
The template supports the following parameters:
Usage example:
dotnet new benchmark -n=MyCompany.Namespace.Benchmarks -b=MyBechmark -f="netstandard2.0;net472"
The template is a library, not as proposed a
exe
- I suggest that users should take advantage of the dotnet global tool to run the benchmarks, instead of creating a console app.The
config
parameter will conditionally add a benchmark config class and reference it inside the the benchmark class.The documentation will be delivered as soon the template is approved.
Closes #1028