Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Props memory benchmark #1617

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ProtoActor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node2", "benchmarks\GossipB
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Messages", "benchmarks\GossipBenchmark\Messages\Messages.csproj", "{2D6F8A17-00B5-41C0-BCF3-1DD733E7C110}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PropsBenchmark", "benchmarks\PropsBenchmark\PropsBenchmark.csproj", "{31A0025C-008E-4961-A82A-842C806567F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1215,6 +1217,18 @@ Global
{2D6F8A17-00B5-41C0-BCF3-1DD733E7C110}.Release|x64.Build.0 = Release|Any CPU
{2D6F8A17-00B5-41C0-BCF3-1DD733E7C110}.Release|x86.ActiveCfg = Release|Any CPU
{2D6F8A17-00B5-41C0-BCF3-1DD733E7C110}.Release|x86.Build.0 = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|x64.ActiveCfg = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|x64.Build.0 = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|x86.ActiveCfg = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Debug|x86.Build.0 = Debug|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|Any CPU.Build.0 = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|x64.ActiveCfg = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|x64.Build.0 = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|x86.ActiveCfg = Release|Any CPU
{31A0025C-008E-4961-A82A-842C806567F0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1327,6 +1341,7 @@ Global
{048ACA91-191B-4B37-93DF-CC603D8E1736} = {3AD895C6-2E1D-40FE-9055-DD4F40E7FFFA}
{DCB884F7-18D4-4E22-A2D2-91DEC7F9B062} = {3AD895C6-2E1D-40FE-9055-DD4F40E7FFFA}
{2D6F8A17-00B5-41C0-BCF3-1DD733E7C110} = {3AD895C6-2E1D-40FE-9055-DD4F40E7FFFA}
{31A0025C-008E-4961-A82A-842C806567F0} = {0F3AB331-C042-4371-A2F0-0AFDFA13DC9F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CD0D1E44-8118-4682-8793-6B20ABFA824C}
Expand Down
23 changes: 23 additions & 0 deletions benchmarks/PropsBenchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//this is not intended to show performance, nor any functionality
//this is only for measuring Props memory consumption

using PropsBenchmark;
using Proto;

var system = new ActorSystem();
var props = Props.FromFunc(ctx => Task.CompletedTask);

Console.WriteLine("Starting");
for (var i = 0; i < 1_000_000; i++)
{
var p = props.WithOnInit(ctx => {
ctx.Set(new SomeState("SomeId" + i));
}
);

var pid = system.Root.Spawn(p);
}

Console.WriteLine("Done");

Console.ReadLine();
14 changes: 14 additions & 0 deletions benchmarks/PropsBenchmark/PropsBenchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Proto.Cluster\Proto.Cluster.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions benchmarks/PropsBenchmark/SomeState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// -----------------------------------------------------------------------
// <copyright file = "SomeState.cs" company = "Asynkron AB">
// Copyright (C) 2015-2022 Asynkron AB All rights reserved
// </copyright>
// -----------------------------------------------------------------------
namespace PropsBenchmark;

public record SomeState(string Name);