-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MaterializationBenchmarks.cs
49 lines (42 loc) · 1.42 KB
/
MaterializationBenchmarks.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="MaterializationBenchmarks.cs" company="Akka.NET Project">
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Benchmarks.Configurations;
using Akka.Streams;
using Akka.Streams.Dsl;
using BenchmarkDotNet.Attributes;
namespace Akka.Benchmarks.Streams
{
[Config(typeof(MicroBenchmarkConfig))]
public class MaterializationBenchmarks
{
private ActorSystem system;
private ActorMaterializer materializer;
private IRunnableGraph<Task> simpleGraph;
[GlobalSetup]
public void Setup()
{
system = ActorSystem.Create("system");
materializer = system.Materializer();
simpleGraph = Source.Single(1)
.Select(x => x + 1)
.ToMaterialized(Sink.ForEach<int>(i => { }), Keep.Right);
}
[GlobalCleanup]
public void Cleanup()
{
materializer.Dispose();
system.Dispose();
}
[Benchmark]
public void Actor_materializer_run_simple_linear_graph()
{
simpleGraph.Run(materializer);
}
}
}