Skip to content

Commit 9655665

Browse files
committed
Merge branch 'master' into reduce-async-overhead
2 parents 2cbdf2c + 554127b commit 9655665

61 files changed

Lines changed: 315 additions & 265 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The measured data can be exported to different formats (md, html, csv, xml, json
110110
*Supported runtimes:* .NET 5+, .NET Framework 4.6.1+, .NET Core 2.0+, Mono, NativeAOT
111111
*Supported languages:* C#, F#, Visual Basic
112112
*Supported OS:* Windows, Linux, macOS
113-
*Supported architectures:* x86, x64, ARM, ARM64 and Wasm
113+
*Supported architectures:* x86, x64, ARM, ARM64, Wasm and LoongArch64
114114

115115
## Features
116116

appveyor.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ skip_tags: true
2121
# environment configuration #
2222
#---------------------------------#
2323

24-
os: Visual Studio 2019
24+
os: Visual Studio 2022
2525

2626
# scripts that are called at very beginning, before repo cloning
2727
init:
2828
- git config --global core.autocrlf input
2929

30+
# add Visual C++ toolset to $path so NativeAOT tests can build native executables
31+
before_build:
32+
- call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
33+
3034
#---------------------------------#
3135
# build configuration #
3236
#---------------------------------#

build/Program.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Cake.Common.IO;
99
using Cake.Common.Net;
1010
using Cake.Common.Tools.DotNet;
11+
using Cake.Common.Tools.DotNet.MSBuild;
12+
using Cake.Common.Tools.DotNet.Restore;
1113
using Cake.Common.Tools.DotNet.Run;
1214
using Cake.Common.Tools.DotNetCore.Build;
1315
using Cake.Common.Tools.DotNetCore.MSBuild;
@@ -93,18 +95,29 @@ public BuildContext(ICakeContext context)
9395
MaxCpuCount = 1
9496
};
9597
MsBuildSettings.WithProperty("UseSharedCompilation", "false");
98+
99+
// NativeAOT build requires VS C++ tools to be added to $path via vcvars64.bat
100+
// but once we do that, dotnet restore fails with:
101+
// "Please specify a valid solution configuration using the Configuration and Platform properties"
102+
if (context.IsRunningOnWindows())
103+
{
104+
MsBuildSettings.WithProperty("Platform", "Any CPU");
105+
}
96106
}
97107

98108
private DotNetCoreTestSettings GetTestSettingsParameters(FilePath logFile, string tfm)
99109
{
100-
return new DotNetCoreTestSettings
110+
var settings = new DotNetCoreTestSettings
101111
{
102112
Configuration = BuildConfiguration,
103113
Framework = tfm,
104114
NoBuild = true,
105115
NoRestore = true,
106116
Loggers = new[] { "trx", $"trx;LogFileName={logFile.FullPath}" }
107117
};
118+
// force the tool to not look for the .dll in platform-specific directory
119+
settings.EnvironmentVariables["Platform"] = "";
120+
return settings;
108121
}
109122

110123
public void RunTests(FilePath projectFile, string alias, string tfm)
@@ -260,7 +273,11 @@ public class RestoreTask : FrostingTask<BuildContext>
260273
{
261274
public override void Run(BuildContext context)
262275
{
263-
context.DotNetRestore(context.SolutionFile.FullPath);
276+
context.DotNetRestore(context.SolutionFile.FullPath,
277+
new DotNetRestoreSettings
278+
{
279+
MSBuildSettings = context.MsBuildSettings
280+
});
264281
}
265282
}
266283

@@ -293,8 +310,8 @@ public override bool ShouldRun(BuildContext context)
293310
public override void Run(BuildContext context)
294311
{
295312
var targetFrameworks = context.IsRunningOnWindows()
296-
? new[] { "net461", "net5.0" }
297-
: new[] { "net5.0" };
313+
? new[] { "net461", "net6.0" }
314+
: new[] { "net6.0" };
298315

299316
foreach (var targetFramework in targetFrameworks)
300317
context.RunTests(context.UnitTestsProjectFile, "UnitTests", targetFramework);
@@ -327,7 +344,7 @@ public override bool ShouldRun(BuildContext context)
327344

328345
public override void Run(BuildContext context)
329346
{
330-
context.RunTests(context.IntegrationTestsProjectFile, "IntegrationTests", "net5.0");
347+
context.RunTests(context.IntegrationTestsProjectFile, "IntegrationTests", "net6.0");
331348
}
332349
}
333350

@@ -349,12 +366,14 @@ public override void Run(BuildContext context)
349366
{
350367
Configuration = context.BuildConfiguration,
351368
OutputDirectory = context.ArtifactsDirectory.FullPath,
352-
ArgumentCustomization = args => args.Append("--include-symbols").Append("-p:SymbolPackageFormat=snupkg")
369+
ArgumentCustomization = args => args.Append("--include-symbols").Append("-p:SymbolPackageFormat=snupkg"),
370+
MSBuildSettings = context.MsBuildSettings
353371
};
354372
var settingsTemplate = new DotNetCorePackSettings
355373
{
356374
Configuration = context.BuildConfiguration,
357-
OutputDirectory = context.ArtifactsDirectory.FullPath
375+
OutputDirectory = context.ArtifactsDirectory.FullPath,
376+
MSBuildSettings = context.MsBuildSettings
358377
};
359378

360379
foreach (var project in context.AllPackableSrcProjects)

build/global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.403",
3+
"version": "6.0.201",
44
"rollForward": "disable"
55
}
66
}

docs/articles/contributing/building.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
There are two recommended options to build BenchmarkDotNet from source:
44

5-
## Option A (Windows only) - Visual Studio
5+
## Visual Studio
66

7-
- [Visual Studio 2017 version 15.7 Preview 4 or higher](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise).
7+
- [Visual Studio](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise) with .NET 4.6.1 SDK and F# support.
88

9-
- Visual Studio 2017 doesn't have installed necessary the .NET Core SDK 2.1 Preview 1, but you can get it from the [Installing the .Net Core SDK page](https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1). You may also need [.NET Core Runtime 2.1 Preview 1](https://www.microsoft.com/net/download/dotnet-core/runtime-2.1.0-preview1).
10-
11-
- Visual Studio 2017 should have installed “F# language support” feature. You can also install the support [directly as a separate download](https://www.microsoft.com/en-us/download/details.aspx?id=48179).
9+
- [.NET 5 SDK](https://dotnet.microsoft.com/download).
1210

1311
Once all the necessary tools are in place, building is trivial. Simply open solution file **BenchmarkDotNet.sln** that lives at the base of the repository and run Build action.
1412

15-
## Option B (Windows, Linux, macOS) - Cake (C# Make)
13+
## Cake (C# Make)
1614

1715
[Cake (C# Make)](http://cakebuild.net/) is a cross platform build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages.
1816

docs/articles/contributing/debugging.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
There should be two debug profiles available in VS drop down
44

55
![](https://cloud.githubusercontent.com/assets/6011991/15627671/89f2405a-24eb-11e6-8bd1-c9d45613e0f6.png "Debug profiles")
6-
7-
However due to VS 2017 RC4 bug it seems that it's impossible to choose as of 2/19/2017. If you want to change it then please edit the project file (.csproj) and set your order - the first framework moniker is always used. `<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>`

docs/articles/contributing/development.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/articles/contributing/disassembler.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ The disassembler might looks scarry, but once you know how it works and how to d
77
We have 3 disassemblers:
88

99
- Mono
10-
- x64 for Windows
10+
- x64 for Windows and Linux
1111
- x86 for Windows
1212

1313
The MonoDisassembler is very simple: it spawns Mono with the right arguments to get the asm, Mono prints the output to the console and we just parse it. Single class does the job: `MonoDisassembler`.
1414

1515
When it comes to Windows disassemblers it's not so easy. To obtain the disassm we are using ClrMD. ClrMD can attach only to the process of same bitness (architecture).
16-
This is why we have two dissasemblers: x64 and x86. The code is the same (single class, linked in two projects) but compiled for two different architectures.
16+
This is why we have two dissasemblers: x64 and x86. The code is the same (single class, linked in two projects) but compiled for two different architectures. We keep both disassemblers in the resources of the BenchmarkDotNet.dll. When we need the disassembler, we search for it in the resources, copy it to the disk and run (it's an exe).
17+
18+
On Linux it's simpler (only x64 is supported) and we don't spawn a new process (everything is done in-proc).
1719

18-
Unfortunately ClrMD is not a signed dll. This is why, we keep both diassemblers in the resources of the BenchmarkDotNet.dll.
19-
When we need the disassembler, we search for it in the resources, copy it to the disk and run (it's an exe).
2020

2121
### How to debug the disassembler
2222

23-
You need to create a new project which executes the code that you would like to disassemble. It can be a simple console app.
24-
In this app, you need to run the desired code (to get it jitted) and just don't exit. Before you exit, you have to attach with Disassembler to given process.
23+
You need to create a new console app project which executes the code that you would like to disassemble. In this app, you need to run the desired code (to get it jitted) and just don't exit before attaching the disassembler and getting the disassembly.
2524

26-
Disassembler requires some arguments to run: id of the process to attach, full type name of the type which contains desired method, name of desired method and what should be disassembled: asm, IL, C#, prolog & epilog.
25+
Disassembler requires some arguments to run: id of the process to attach, full type name of the type which contains desired method, name of desired method and few other (see the example below).
2726

2827
Personally I use following code to run the console app and print arguments that are required to attach to it:
2928

@@ -76,7 +75,7 @@ namespace Sample
7675

7776
Once you configure your app, you should run it. It will give you an output similar to this:
7877

79-
`13672 ConsoleApp1.RandomSort ArraySort True 7 C:\Users\adsitnik\AppData\Local\Temp\tmpDCB9.tmp.xml`
78+
`13672 Sample.Program Benchmark True 7 C:\Users\adsitnik\AppData\Local\Temp\tmpDCB9.tmp.xml`
8079

8180
Now you go to BenchmarkDotNet solution, select desired Disassembler project in the Solution Explorer and Set it as Startup project. After this you go to the project's properties and in the Debug tab copy-paste the arguments for the disassembler. Now when you start debugging, your IDE will spawn new process of the disassembler with the right arguments to attach to the desired exe. You should be able to debug it like any other app.
8281

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# Running Tests
22

3-
* To run "Classic" tests build the solution and run runClassicTests.cmd in the tests directory or comment out the `netcoreapp1.0` part of all project.json files
4-
that belong to the testing projects.
5-
* To run "Core" tests you just need to open Test Explorer in Visual Studio and rebuild the solution. Then tests show up in Test Explorer and you can simply run them.
3+
To run all tests just run the following command in the repo root:
64

7-
> [!IMPORTANT]
8-
> Remember to do both before pulling a PR or publishing new version
5+
```cmd
6+
dotnet test -c Release BenchmarkDotNet.sln
7+
```
98

10-
* For some unit tests (e.g. for exporter tests) BenchmarkDotNet uses [approval tests'](http://approvaltests.sourceforge.net/) implementation for .NET: [ApprovalTests.Net](https://github.com/approvals/ApprovalTests.Net).
11-
* The expected value for each test is stored in a `*.approved.txt` file located near the test source file in the repository. ApprovalTests.NET generates approved file's names automatically according test name and its parameters. This files must be added under the source control.
12-
* It also creates a `*.received` file for each failed test. You can use different reporters for convenient file comparison. By default we use XUnit2Reporter, so you can find test run results on the test runner console as usual. You can add [UseReporter(typeof(KDiffReporter))] on test class and then ApprovalTests will open KDiff for each failed test. This way you can easily understand what's the difference between approved and received values and choose the correct one.
9+
Most of the tests projects target `net461` and `net5.0`. If the change that you want to test is not specific to any particular runtime, you can run the tests for one of them.
10+
11+
```cmd
12+
dotnet test -c Release -f net5.0 BenchmarkDotNet.sln
13+
```
14+
15+
You should be able to run all of tests from your IDE as well.
16+
17+
## Approval Tests
18+
19+
For some unit tests (e.g. for exporter tests) BenchmarkDotNet uses [approval tests'](http://approvaltests.sourceforge.net/) implementation for .NET: [ApprovalTests.Net](https://github.com/approvals/ApprovalTests.Net).
20+
* The expected value for each test is stored in a `*.approved.txt` file located near the test source file in the repository. ApprovalTests.NET generates approved file's names automatically according test name and its parameters. This files must be added under the source control.
21+
* It also creates a `*.received` file for each failed test. You can use different reporters for convenient file comparison. By default we use XUnit2Reporter, so you can find test run results on the test runner console as usual. You can add [UseReporter(typeof(KDiffReporter))] on test class and then ApprovalTests will open KDiff for each failed test. This way you can easily understand what's the difference between approved and received values and choose the correct one.

docs/articles/contributing/toc.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
href: debugging.md
55
- name: Running tests
66
href: running-tests.md
7-
- name: Development
8-
href: development.md
97
- name: Miscellaneous topics
108
href: miscellaneous.md
119
- name: Disassembler

0 commit comments

Comments
 (0)