-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathIntroInProcess.cs
More file actions
49 lines (44 loc) · 1.29 KB
/
IntroInProcess.cs
File metadata and controls
49 lines (44 loc) · 1.29 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
45
46
47
48
49
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
namespace BenchmarkDotNet.Samples
{
[Config(typeof(Config))]
[UseLocalJobOnly]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[MemoryDiagnoser]
public class IntroInProcess
{
private class Config : ManualConfig
{
public Config()
{
AddJob(Job.MediumRun
.WithLaunchCount(1)
.WithId("OutOfProc"));
AddJob(Job.MediumRun
.WithLaunchCount(1)
.WithToolchain(InProcessEmitToolchain.Default)
.WithId("InProcess"));
}
}
[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)
{
}
}
}