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

Dictionary benchmarks #2904

Draft
wants to merge 22 commits into
base: develop/main374
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SharpFuzz" Version="2.1.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Opc.Ua.Server/Server/StandardServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3141,7 +3141,7 @@ protected void ShutDownDelay()
ServerInternal.Status.Variable.ClearChangeMasks(ServerInternal.DefaultSystemContext, true);

// exit if all client connections are closed.
var sessions = ServerInternal.SessionManager.GetSessions().Count;
var sessions = ServerInternal.SessionManager.GetSessionCount();
if (sessions == 0)
{
break;
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Opc.Ua.Server/Session/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,12 @@ public event EventHandler<ValidateSessionLessRequestEventArgs> ValidateSessionLe
}
}

/// <inheritdoc/>
public int GetSessionCount()
{
return m_sessions.Count;
}

/// <inheritdoc/>
public IList<Session> GetSessions()
{
Expand Down
2 changes: 1 addition & 1 deletion Stack/Opc.Ua.Core/Stack/Bindings/BufferManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class Allocation
private readonly object m_lock = new object();
private int m_allocated;
private int m_id;
private SortedDictionary<int, Allocation> m_allocations = new SortedDictionary<int, Allocation>();
private Dictionary<int, Allocation> m_allocations = new Dictionary<int, Allocation>();
#else
private const byte kCookieLength = 1;
#endif
Expand Down
65 changes: 56 additions & 9 deletions Tests/Common/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,66 @@
* ======================================================================*/

using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Validators;
using Opc.Ua;

static class Program
[assembly: Config(typeof(BenchmarksDefaultConfig))]

class BenchmarksDefaultConfig : ManualConfig
{
// Main Method
public static void Main(String[] args)
public BenchmarksDefaultConfig()
{
IConfig config = ManualConfig.Create(DefaultConfig.Instance)
// need this option because of reference to nunit.framework
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
;
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
if (Program.CmdLineUsed)
{
var defaults = DefaultConfig.Instance;
foreach (var exporter in defaults.GetExporters())
{
AddExporter(exporter);
}
foreach (var logger in defaults.GetLoggers())
{
AddLogger(logger);
}
foreach (var analyser in defaults.GetAnalysers())
{
AddAnalyser(analyser);
}
foreach (var validator in defaults.GetValidators())
{
AddValidator(validator);
}
WithOptions(ConfigOptions.DisableOptimizationsValidator);
}
else
{
AddJob(Job.Dry);
AddLogger(ConsoleLogger.Default);
AddValidator(JitOptimizationsValidator.DontFailOnError);
}
}
}

static class Program
{
/// <summary>
/// Whether command line was used to start.
/// </summary>
public static bool CmdLineUsed = false;

// Main Method
public static void Main(string[] args)
{
IConfig config = ManualConfig.Create(DefaultConfig.Instance)
// need this option because of reference to nunit.framework
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
;
CmdLineUsed = true;
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Console" Version="3.18.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
Expand Down
2 changes: 2 additions & 0 deletions Tests/Opc.Ua.Client.Tests/Opc.Ua.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="NUnit.Console" Version="3.18.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Tests/Opc.Ua.Core.Tests/Opc.Ua.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Console" Version="3.18.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
Expand All @@ -30,7 +32,7 @@
<Choose>
<When Condition="'$(TargetFramework)' == 'net462'">
</When>
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
</When>
<Otherwise>
<PropertyGroup Condition="'$(DisableECCTests)' != 'true'">
Expand Down
Loading
Loading