Skip to content

Commit 1938a20

Browse files
added dedicated footprint for measuring Actor memory footprint (#5047)
1 parent 73d19af commit 1938a20

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="ActorMemoryFootprintBenchmarks.cs" company="Akka.NET Project">
3+
// Copyright (C) 2009-2021 Lightbend Inc. <http://www.lightbend.com>
4+
// Copyright (C) 2013-2021 .NET Foundation <https://github.com/akkadotnet/akka.net>
5+
// </copyright>
6+
//-----------------------------------------------------------------------
7+
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
using Akka.Actor;
13+
using Akka.Benchmarks.Configurations;
14+
using BenchmarkDotNet.Attributes;
15+
16+
namespace Akka.Benchmarks.Actor
17+
{
18+
[Config(typeof(MicroBenchmarkConfig))]
19+
public class ActorMemoryFootprintBenchmark
20+
{
21+
public ActorSystem Sys;
22+
public Props Props;
23+
24+
[GlobalSetup]
25+
public void Setup()
26+
{
27+
Sys = ActorSystem.Create("Bench");
28+
Props = Props.Create(() => new TempActor());
29+
}
30+
31+
private class TempActor : UntypedActor
32+
{
33+
protected override void OnReceive(object message)
34+
{
35+
36+
}
37+
}
38+
39+
[Benchmark]
40+
public void SpawnActor()
41+
{
42+
Sys.ActorOf(Props);
43+
}
44+
45+
[GlobalCleanup]
46+
public async Task Cleanup()
47+
{
48+
await Sys.Terminate();
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)