Skip to content

Commit 1decbd5

Browse files
author
Bart Koelman
committed
cibuild fixes
1 parent a231651 commit 1decbd5

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Examples/JsonApiDotNetCoreExample/Startups/EmptyStartup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public virtual void ConfigureServices(IServiceCollection services)
1515
{
1616
}
1717

18+
// ReSharper disable once UnusedMemberInSuper.Global
19+
// ReSharper disable once UnusedParameter.Global
1820
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment environment, ILoggerFactory loggerFactory)
1921
{
2022
}

src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using System.Linq;
6+
using System.Runtime.InteropServices;
67
using System.Text;
78
using System.Threading;
89
using JetBrains.Annotations;
@@ -21,16 +22,19 @@ public sealed class CascadingCodeTimer : ICodeTimer
2122

2223
static CascadingCodeTimer()
2324
{
24-
// Be default, measurements using Stopwatch can differ 25%-30% on the same function on the same computer.
25-
// The steps below ensure to get an accuracy of 0.1%-0.2%. With this accuracy, algorithms can be tested and compared.
26-
// https://www.codeproject.com/Articles/61964/Performance-Tests-Precise-Run-Time-Measurements-wi
25+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
26+
{
27+
// Be default, measurements using Stopwatch can differ 25%-30% on the same function on the same computer.
28+
// The steps below ensure to get an accuracy of 0.1%-0.2%. With this accuracy, algorithms can be tested and compared.
29+
// https://www.codeproject.com/Articles/61964/Performance-Tests-Precise-Run-Time-Measurements-wi
2730

28-
// The most important thing is to prevent switching between CPU cores or processors. Switching dismisses the cache, etc. and has a huge performance impact on the test.
29-
Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2);
31+
// The most important thing is to prevent switching between CPU cores or processors. Switching dismisses the cache, etc. and has a huge performance impact on the test.
32+
Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2);
3033

31-
// To get the CPU core more exclusively, we must prevent that other threads can use this CPU core. We set our process and thread priority to achieve this.
32-
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
33-
Thread.CurrentThread.Priority = ThreadPriority.Highest;
34+
// To get the CPU core more exclusively, we must prevent that other threads can use this CPU core. We set our process and thread priority to achieve this.
35+
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
36+
Thread.CurrentThread.Priority = ThreadPriority.Highest;
37+
}
3438
}
3539

3640
/// <inheritdoc />

0 commit comments

Comments
 (0)