-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathConfigurationManagerLoadBenchmark.cs
More file actions
45 lines (41 loc) · 1.42 KB
/
ConfigurationManagerLoadBenchmark.cs
File metadata and controls
45 lines (41 loc) · 1.42 KB
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
using BenchmarkDotNet.Attributes;
using Terminal.Gui.Configuration;
namespace Terminal.Gui.Benchmarks.Configuration;
/// <summary>
/// Measures the cold-start cost of loading the embedded library configuration:
/// <c>ConfigurationManager.Disable (true)</c> → <c>Enable (ConfigLocations.LibraryResources)</c> → <c>Apply ()</c>.
/// This is the app-startup hot path.
/// </summary>
/// <remarks>
/// <para>
/// Run:
/// <code>dotnet run --project Tests/Benchmarks -c Release -- --filter '*ConfigurationManagerLoad*'</code>
/// </para>
/// </remarks>
[MemoryDiagnoser]
[BenchmarkCategory ("Configuration")]
public class ConfigurationManagerLoadBenchmark
{
/// <summary>Resets ConfigurationManager to a clean state before each iteration.</summary>
[IterationSetup]
public void IterationSetup ()
{
ConfigurationManager.Disable (true);
}
/// <summary>
/// Loads the embedded library configuration from scratch and applies it.
/// Captures the full deserialize + merge + apply path.
/// </summary>
[Benchmark]
public void LoadAndApply ()
{
ConfigurationManager.Enable (ConfigLocations.LibraryResources);
ConfigurationManager.Apply ();
}
/// <summary>Ensures ConfigurationManager is disabled after all iterations.</summary>
[GlobalCleanup]
public void Cleanup ()
{
ConfigurationManager.Disable (true);
}
}