-
Notifications
You must be signed in to change notification settings - Fork 11
/
SamplingBenchmark.cs
49 lines (42 loc) · 1.41 KB
/
SamplingBenchmark.cs
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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SamplingBenchmark.cs">
// Copyright (c) 2020 Johannes Deml. All rights reserved.
// </copyright>
// <author>
// Johannes Deml
// public@deml.io
// </author>
// --------------------------------------------------------------------------------------------------------------------
using BenchmarkDotNet.Attributes;
namespace NetworkBenchmark
{
[Config(typeof(SamplingBenchmarkConfig))]
public class SamplingBenchmark : APredefinedBenchmark
{
[Params(NetworkLibrary.ENet, NetworkLibrary.LiteNetLib, NetworkLibrary.NetCoreServer)]
public NetworkLibrary Library { get; set; }
[Params(1, Priority = 100)]
public override int Clients { get; set; }
public override int MessageTarget { get; set; } = 100_000;
protected override BenchmarkMode Mode => BenchmarkMode.Sampling;
protected override NetworkLibrary LibraryTarget => Library;
[GlobalSetup(Target = nameof(SampleSimpleEcho))]
public void PrepareSamplingBenchmark()
{
BenchmarkCoordinator.ApplyPredefinedConfiguration();
var config = BenchmarkCoordinator.Config;
config.ParallelMessages = 10;
config.MessageByteSize = 128;
PrepareBenchmark();
}
[Benchmark]
public long SampleSimpleEcho()
{
return RunBenchmark();
}
public override string ToString()
{
return "GarbageBenchmark";
}
}
}