Slide 35
Slide 35 text
[Params(10, 20, 40)]
public int PipelineDepth { get; set; }
for (int i = 0; i < PipelineDepth; i++)
for (int i = 0; i < PipelineDepth; i++)
[ShortRunJob]
1
[MemoryDiagnoser]
2
public class PipelineExecution {
3
4
5
6
7
8
[GlobalSetup]
9
public void SetUp() {
10
behaviorContext = new BehaviorContext();
11
12
pipelineModificationsBeforeOptimizations = new PipelineModifications();
13
14
{
15
pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
16
typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior()));
17
}
18
19
pipelineModificationsAfterOptimizations = new PipelineModifications();
20
21
{
22
pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
23
typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization()));
24
}
25
26
pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(),
27
pipelineModificationsBeforeOptimizations);
28
pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(),
29
pipelineModificationsAfterOptimizations);
30
}
31
32
[Benchmark(Baseline = true)]
33
public async Task Before() {
34
await pipelineBeforeOptimizations.Invoke(behaviorContext);
35
}
36
37
[Benchmark]
38
public async Task After() {
39
await pipelineAfterOptimizations.Invoke(behaviorContext);
40
}
41
}
42
[ShortRunJob]
[MemoryDiagnoser]
1
2
public class PipelineExecution {
3
4
[Params(10, 20, 40)]
5
public int PipelineDepth { get; set; }
6
7
8
[GlobalSetup]
9
public void SetUp() {
10
behaviorContext = new BehaviorContext();
11
12
pipelineModificationsBeforeOptimizations = new PipelineModifications();
13
for (int i = 0; i < PipelineDepth; i++)
14
{
15
pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
16
typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior()));
17
}
18
19
pipelineModificationsAfterOptimizations = new PipelineModifications();
20
for (int i = 0; i < PipelineDepth; i++)
21
{
22
pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
23
typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization()));
24
}
25
26
pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(),
27
pipelineModificationsBeforeOptimizations);
28
pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(),
29
pipelineModificationsAfterOptimizations);
30
}
31
32
[Benchmark(Baseline = true)]
33
public async Task Before() {
34
await pipelineBeforeOptimizations.Invoke(behaviorContext);
35
}
36
37
[Benchmark]
38
public async Task After() {
39
await pipelineAfterOptimizations.Invoke(behaviorContext);
40
}
41
}
42
[Benchmark(Baseline = true)]
public async Task Before() {
await pipelineBeforeOptimizations.Invoke(behaviorContext);
}
[Benchmark]
public async Task After() {
await pipelineAfterOptimizations.Invoke(behaviorContext);
}
[ShortRunJob]
1
[MemoryDiagnoser]
2
public class PipelineExecution {
3
4
[Params(10, 20, 40)]
5
public int PipelineDepth { get; set; }
6
7
8
[GlobalSetup]
9
public void SetUp() {
10
behaviorContext = new BehaviorContext();
11
12
pipelineModificationsBeforeOptimizations = new PipelineModifications();
13
for (int i = 0; i < PipelineDepth; i++)
14
{
15
pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
16
typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior()));
17
}
18
19
pipelineModificationsAfterOptimizations = new PipelineModifications();
20
for (int i = 0; i < PipelineDepth; i++)
21
{
22
pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
23
typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization()));
24
}
25
26
pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(),
27
pipelineModificationsBeforeOptimizations);
28
pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(),
29
pipelineModificationsAfterOptimizations);
30
}
31
32
33
34
35
36
37
38
39
40
41
}
42
[ShortRunJob]
[MemoryDiagnoser]
public class PipelineExecution {
[Params(10, 20, 40)]
public int PipelineDepth { get; set; }
[GlobalSetup]
public void SetUp() {
behaviorContext = new BehaviorContext();
pipelineModificationsBeforeOptimizations = new PipelineModifications();
for (int i = 0; i < PipelineDepth; i++)
{
pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior()));
}
pipelineModificationsAfterOptimizations = new PipelineModifications();
for (int i = 0; i < PipelineDepth; i++)
{
pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(),
typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization()));
}
pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(),
pipelineModificationsBeforeOptimizations);
pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(),
pipelineModificationsAfterOptimizations);
}
[Benchmark(Baseline = true)]
public async Task Before() {
await pipelineBeforeOptimizations.Invoke(behaviorContext);
}
[Benchmark]
public async Task After() {
await pipelineAfterOptimizations.Invoke(behaviorContext);
}
}
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
Benchmarking the pipeline