-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathIntroGcMode.cs
More file actions
44 lines (40 loc) · 1.33 KB
/
IntroGcMode.cs
File metadata and controls
44 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Order;
namespace BenchmarkDotNet.Samples
{
[Config(typeof(Config))]
[UseLocalJobOnly]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[MemoryDiagnoser]
public class IntroGcMode
{
private class Config : ManualConfig
{
public Config()
{
AddJob(Job.MediumRun.WithGcServer(true).WithGcForce(true).WithId("ServerForce"));
AddJob(Job.MediumRun.WithGcServer(true).WithGcForce(false).WithId("Server"));
AddJob(Job.MediumRun.WithGcServer(false).WithGcForce(true).WithId("Workstation"));
AddJob(Job.MediumRun.WithGcServer(false).WithGcForce(false).WithId("WorkstationForce"));
}
}
[Benchmark(Description = "new byte[10kB]")]
public byte[] Allocate()
{
return new byte[10000];
}
[Benchmark(Description = "stackalloc byte[10kB]")]
public unsafe void AllocateWithStackalloc()
{
var array = stackalloc byte[10000];
Consume(array);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void Consume(byte* input)
{
}
}
}