Skip to content

Commit

Permalink
Action benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-andersson-at-westermo committed Jun 10, 2024
1 parent 84cf78c commit 30e399f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,45 @@ public class ParsingBenchmarks
CommandSubType = Ietf.Connection.Oriented.Oam.YangNode.CommandSubTypeIdentity.Proactive
};

private static readonly Ietf.Alarms.YangNode.AlarmsContainer.AlarmListContainer.AlarmEntry.SetOperatorStateInput
SetOperatorStateInput = new()
{
State = Ietf.Alarms.YangNode.WritableOperatorState.Ack,
Text = "Acked"
};

private static readonly Ietf.Alarms.YangNode.AlarmsContainer alarmsContainer = new()
{
AlarmList = new Ietf.Alarms.YangNode.AlarmsContainer.AlarmListContainer
{
Alarm =
[
new Ietf.Alarms.YangNode.AlarmsContainer.AlarmListContainer.AlarmEntry
{
TimeCreated = "2015-01-23T12:23:34Z",
Resource = "something",
AlarmTypeId = Ietf.Alarms.YangNode.AlarmTypeIdIdentity.AlarmTypeId,
IsCleared = false,
LastRaised = "2014-01-23T12:23:34Z",
LastChanged = "2014-01-22T12:23:34Z",
PerceivedSeverity = Ietf.Alarms.YangNode.Severity.Critical,
AlarmText = "boo"
},
new Ietf.Alarms.YangNode.AlarmsContainer.AlarmListContainer.AlarmEntry
{
TimeCreated = "2015-01-23T12:25:34Z",
Resource = "something",
AlarmTypeId = Ietf.Alarms.YangNode.AlarmTypeIdIdentity.AlarmTypeId,
IsCleared = false,
LastRaised = "2014-01-23T12:28:34Z",
LastChanged = "2014-01-22T12:22:34Z",
PerceivedSeverity = Ietf.Alarms.YangNode.Severity.Critical,
AlarmText = "baa"
}
]
}
};

[GlobalSetup]
public void Setup()
{
Expand Down Expand Up @@ -106,6 +145,13 @@ public MemoryStream ToMemoryStream()
{
return await Ietf.Connection.Oriented.Oam.YangNode.Traceroute(channel, 123, input);
}

[Benchmark]
public async Task SetOperatorStateRoundTrip()
{
await alarmsContainer.AlarmList!.Alarm![0]
.SetOperatorState(channel, 123, alarmsContainer, SetOperatorStateInput);
}
}

internal class BenchmarkingChannel(IYangServer server) : IChannel
Expand Down

0 comments on commit 30e399f

Please sign in to comment.