Skip to content

Commit f403053

Browse files
Standardize logging and update file headers
Updated `Last Modified On` date to `01-31-2025` across multiple files. Added new logging methods (`LogError`, `LogInfo`, `LogMessage`, `LogWarning`) to the `Benchmark` class. Replaced `ConsoleLogger.Default.WriteLine` calls with `LogInfo` in various benchmark classes. Removed `BenchmarkDotNet.Loggers` namespace import where no longer needed. Changed `Properties` namespace to `Resources` in `CollectionBenchmark` for JSON resources. Made minor formatting changes and updated comments to reflect new logging methods.
1 parent 83c4046 commit f403053

14 files changed

Lines changed: 67 additions & 48 deletions

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/Benchmark.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 11-13-2021
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-30-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="Benchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -162,6 +162,31 @@ protected Benchmark()
162162
/// <value>The consumer instance.</value>
163163
private Consumer Consumer { get; } = new();
164164

165+
/// <summary>
166+
/// Logs an error message.
167+
/// </summary>
168+
/// <param name="message">The message to log.</param>
169+
protected static void LogError(string message) => LogMessage(LogKind.Error, message);
170+
171+
/// <summary>
172+
/// Logs an informational message.
173+
/// </summary>
174+
/// <param name="message">The message to log.</param>
175+
protected static void LogInfo(string message) => LogMessage(LogKind.Info, message);
176+
177+
/// <summary>
178+
/// Logs a message with the specified log kind.
179+
/// </summary>
180+
/// <param name="logKind">The kind of log message.</param>
181+
/// <param name="message">The message to log.</param>
182+
protected static void LogMessage(LogKind logKind, string message) => ConsoleLogger.Default.WriteLine(logKind, message);
183+
184+
/// <summary>
185+
/// Logs a warning message.
186+
/// </summary>
187+
/// <param name="message">The message to log.</param>
188+
protected static void LogWarning(string message) => LogMessage(LogKind.Warning, message);
189+
165190
/// <summary>
166191
/// Performs cleanup operations. This method should be called at the end of benchmark runs.
167192
/// It logs the cleanup action to the console.

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/CollectionBenchmark.Coordinate.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 04-18-2022
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-05-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="CollectionBenchmark.Coordinate.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -16,7 +16,6 @@
1616
// ***********************************************************************
1717

1818
using System.Collections.ObjectModel;
19-
using BenchmarkDotNet.Loggers;
2019
using DotNetTips.Spargine.Extensions;
2120
using DotNetTips.Spargine.Tester;
2221
using DotNetTips.Spargine.Tester.Models.ValueTypes;
@@ -51,8 +50,8 @@ protected void LoadCoordinateCollections()
5150
this._coordinateArray = [.. RandomData.GenerateCoordinateCollection<Coordinate>(this.MaxCount)];
5251
this._coordinateList = [.. this._coordinateArray];
5352

54-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Coordinate Array Count = {this._coordinateArray.Length}: {nameof(CollectionBenchmark)}.");
55-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Coordinate List Count = {this._coordinateList.Count}: {nameof(CollectionBenchmark)}.");
53+
LogInfo($"Coordinate Array Count = {this._coordinateArray.Length}: {nameof(CollectionBenchmark)}.");
54+
LogInfo($"Coordinate List Count = {this._coordinateList.Count}: {nameof(CollectionBenchmark)}.");
5655
}
5756

5857
/// <summary>

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/CollectionBenchmark.Person.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 04-18-2022
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-05-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="CollectionBenchmark.Person.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -17,7 +17,6 @@
1717
// ***********************************************************************
1818

1919
using System.Collections.ObjectModel;
20-
using BenchmarkDotNet.Loggers;
2120
using DotNetTips.Spargine.Extensions;
2221
using DotNetTips.Spargine.Tester;
2322
using DotNetTips.Spargine.Tester.Models.RefTypes;
@@ -98,9 +97,9 @@ protected void LoadPersonCollections()
9897
this._personValDictionary = this._personValArray.ToDictionary(p => p.Id);
9998

10099
//Display collection counts
101-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Records Array Count={this._personRecordArray.Length}");
102-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Ref Array Count={this._personRefArray.Length}");
103-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Val Array Count={this._personValArray.Length}");
100+
LogInfo($"Records Array Count={this._personRecordArray.Length}");
101+
LogInfo($"Ref Array Count={this._personRefArray.Length}");
102+
LogInfo($"Val Array Count={this._personValArray.Length}");
104103
}
105104

106105
/// <summary>

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/CollectionBenchmark.PersonRecord.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 04-19-2022
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-05-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="CollectionBenchmark.PersonRecord.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -17,7 +17,6 @@
1717
// ***********************************************************************
1818

1919
using System.Collections.ObjectModel;
20-
using BenchmarkDotNet.Loggers;
2120
using DotNetTips.Spargine.Extensions;
2221
using DotNetTips.Spargine.Tester;
2322
using DotNetTips.Spargine.Tester.Models.RefTypes;
@@ -52,8 +51,8 @@ protected void LoadPersonRecordCollections()
5251
this._personRecordList = [.. RandomData.GeneratePersonRecordCollection(this.MaxCount)];
5352
this._personRecordArray = [.. this._personRecordList];
5453

55-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Record List Count = {this._personRecordList.Count}: {nameof(CollectionBenchmark)}.");
56-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Record Array Count = {this._personRecordArray.Length}: {nameof(CollectionBenchmark)}.");
54+
LogInfo($"Record List Count = {this._personRecordList.Count}: {nameof(CollectionBenchmark)}.");
55+
LogInfo($"Record Array Count = {this._personRecordArray.Length}: {nameof(CollectionBenchmark)}.");
5756
}
5857

5958
/// <summary>

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/CollectionBenchmark.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 11-13-2021
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-12-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="CollectionBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -16,7 +16,7 @@
1616
// </summary>
1717
// ***********************************************************************
1818

19-
using BenchmarkDotNet.Loggers;
19+
using DotNetTips.Spargine.Benchmarking.Properties;
2020
using DotNetTips.Spargine.Core.Serialization;
2121
using DotNetTips.Spargine.Tester;
2222
using DotNetTips.Spargine.Tester.Models.RefTypes;
@@ -76,23 +76,23 @@ public partial class CollectionBenchmark : Benchmark
7676
/// <param name="count">The number of <see cref="PersonRecord"/> objects to load. The value must be in the range of 1 to 10000.</param>
7777
/// <returns>An array of <see cref="PersonRecord"/> objects.</returns>
7878
/// <exception cref="ArgumentOutOfRangeException">Thrown when the count is not within the valid range.</exception>
79-
internal static PersonRecord[] LoadPeopleRecordFromResources(int count) => JsonSerialization.LoadCollectionFromJson<PersonRecord>(Properties.Resources.PeopleJson, count, PersonJsonSerializerContext.Default.PersonRecord);
79+
internal static PersonRecord[] LoadPeopleRecordFromResources(int count) => JsonSerialization.LoadCollectionFromJson<PersonRecord>(Resources.PeopleJson, count, PersonJsonSerializerContext.Default.PersonRecord);
8080

8181
/// <summary>
8282
/// Loads a specified number of <see cref="Person{TAddress}"/> reference objects from embedded resources.
8383
/// </summary>
8484
/// <param name="count">The number of <see cref="Person{TAddress}"/> reference objects to load. The value must be in the range of 1 to 10000.</param>
8585
/// <returns>An array of <see cref="Person{TAddress}"/> reference objects.</returns>
8686
/// <exception cref="ArgumentOutOfRangeException">Thrown when the count is not within the valid range.</exception>
87-
internal static Person<Address>[] LoadPeopleRefFromResources(int count) => JsonSerialization.LoadCollectionFromJson<Person<Address>>(Properties.Resources.PeopleJson, count, PersonJsonSerializerContext.Default.Person);
87+
internal static Person<Address>[] LoadPeopleRefFromResources(int count) => JsonSerialization.LoadCollectionFromJson<Person<Address>>(Resources.PeopleJson, count, PersonJsonSerializerContext.Default.Person);
8888

8989
/// <summary>
9090
/// Loads a specified number of Tester.Models.ValueTypes.Person{Tester.Models.ValueTypes.Address} value objects from embedded resources.
9191
/// </summary>
9292
/// <param name="count">The number of Tester.Models.ValueTypes.Person{Tester.Models.ValueTypes.Address} value objects to load. The value must be in the range of 1 to 10000.</param>
9393
/// <returns>An array of Tester.Models.ValueTypes.Person{Tester.Models.ValueTypes.Address} value objects.</returns>
9494
/// <exception cref="ArgumentOutOfRangeException">Thrown when the count is not within the valid range.</exception>
95-
internal static Tester.Models.ValueTypes.Person<Tester.Models.ValueTypes.Address>[] LoadPeopleValFromResources(int count) => JsonSerialization.LoadCollectionFromJson<Tester.Models.ValueTypes.Person<Tester.Models.ValueTypes.Address>>(Properties.Resources.PeopleJson, count, Tester.Models.ValueTypes.PersonJsonValSerializerContext.Default.Person);
95+
internal static Tester.Models.ValueTypes.Person<Tester.Models.ValueTypes.Address>[] LoadPeopleValFromResources(int count) => JsonSerialization.LoadCollectionFromJson<Tester.Models.ValueTypes.Person<Tester.Models.ValueTypes.Address>>(Resources.PeopleJson, count, Tester.Models.ValueTypes.PersonJsonValSerializerContext.Default.Person);
9696

9797
/// <summary>
9898
/// Setups the benchmark instance. This method is called before the benchmark runs and is responsible for initializing the collections and loading the data.
@@ -101,7 +101,7 @@ public override void Setup()
101101
{
102102
base.Setup();
103103

104-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Collection Count={this.MaxCount}: {nameof(CollectionBenchmark)}.");
104+
LogInfo($"Collection Count={this.MaxCount}: {nameof(CollectionBenchmark)}.");
105105

106106
// Load collections
107107
this.LoadCoordinateCollections();

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/CounterBenchmark.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
// Created : 11-13-2021
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-14-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="CounterBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
1111
// </copyright>
1212
// <summary>Abstract class designed for benchmark tests that involve a counter.</summary>
1313
// ***********************************************************************
14-
using BenchmarkDotNet.Loggers;
14+
1515

1616
namespace DotNetTips.Spargine.Benchmarking;
1717

@@ -28,7 +28,7 @@ public abstract class CounterBenchmark : Benchmark
2828
protected CounterBenchmark(int maxCount)
2929
{
3030
this.MaxCount = Math.Max(2, maxCount);
31-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={maxCount}: {nameof(CounterBenchmark)}.");
31+
LogInfo($"Max Count={maxCount}: {nameof(CounterBenchmark)}.");
3232
}
3333

3434
/// <summary>
@@ -44,7 +44,7 @@ public override void Setup()
4444
{
4545
base.Setup();
4646

47-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={this.MaxCount}: {nameof(CounterBenchmark)}.");
47+
LogInfo($"Max Count={this.MaxCount}: {nameof(CounterBenchmark)}.");
4848
}
4949

5050
}

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/FastestLoopingBenchmark.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 04-01-2024
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 10-05-2024
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="FastestLoopingBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -13,7 +13,6 @@
1313
// ***********************************************************************
1414

1515
using BenchmarkDotNet.Attributes;
16-
using BenchmarkDotNet.Loggers;
1716

1817
//`![Spargine 8 - #RockYourCode](6219C891F6330C65927FA249E739AC1F.png;https://www.spargine.net )
1918

@@ -30,7 +29,7 @@ public class FastestLoopingBenchmark : CollectionBenchmark
3029
/// Initializes a new instance of the <see cref="FastestLoopingBenchmark"/> class with a predefined maximum count.
3130
/// This constructor logs the maximum count to the console for informational purposes.
3231
/// </summary>
33-
public FastestLoopingBenchmark() : base(8192) => ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={this.MaxCount}: {nameof(FastestLoopingBenchmark)}.");
32+
public FastestLoopingBenchmark() : base(8192) => LogInfo($"Max Count={this.MaxCount}: {nameof(FastestLoopingBenchmark)}.");
3433

3534
/// <summary>
3635
/// Gets or sets the collection count for the benchmark. This value determines the size of the collection to be used in the benchmark tests.

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/LargeCollectionBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 11-13-2021
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 01-29-2025
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="LargeCollectionBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -33,15 +33,15 @@ public class LargeCollectionBenchmark : CollectionBenchmark
3333
/// Initializes a new instance of the <see cref="LargeCollectionBenchmark"/> class with a maximum count of 8,192.
3434
/// This constructor also logs the maximum count information using the <see cref="ConsoleLogger"/>.
3535
/// </summary>
36-
public LargeCollectionBenchmark() : base(8192) => ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={this.MaxCount}: {nameof(LargeCollectionBenchmark)}.");
36+
public LargeCollectionBenchmark() : base(8192) => LogInfo($"Max Count={this.MaxCount}: {nameof(LargeCollectionBenchmark)}.");
3737

3838
/// <summary>
3939
/// Performs setup operations specific to LargeCollectionBenchmark. This includes logging the current count before and after the base setup is called,
4040
/// and adjusting the MaxCount property to match the current Count. This method is called automatically by the BenchmarkDotNet framework before each benchmark run.
4141
/// </summary>
4242
public override void Setup()
4343
{
44-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Count={this.Count}: {nameof(LargeCollectionBenchmark)}");
44+
LogInfo($"Count={this.Count}: {nameof(LargeCollectionBenchmark)}");
4545

4646
this.MaxCount = this.Count;
4747
base.Setup();

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/SmallCollectionBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 07-28-2022
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 06-22-2024
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="SmallCollectionBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -34,15 +34,15 @@ public class SmallCollectionBenchmark : CollectionBenchmark
3434
/// Initializes a new instance of the <see cref="SmallCollectionBenchmark"/> class with a maximum count of 2,048.
3535
/// This constructor also logs the maximum count information using the <see cref="ConsoleLogger"/>.
3636
/// </summary>
37-
public SmallCollectionBenchmark() : base(2048) => ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={this.MaxCount}: {nameof(SmallCollectionBenchmark)}.");
37+
public SmallCollectionBenchmark() : base(2048) => LogInfo($"Max Count={this.MaxCount}: {nameof(SmallCollectionBenchmark)}.");
3838

3939
/// <summary>
4040
/// Performs setup operations specific to SmallCollectionBenchmark. This includes logging the current count before and after the base setup is called,
4141
/// and adjusting the MaxCount property to match the current Count. This method is called automatically by the BenchmarkDotNet framework before each benchmark run.
4242
/// </summary>
4343
public override void Setup()
4444
{
45-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Count={this.Count}: {nameof(SmallCollectionBenchmark)}");
45+
LogInfo($"Count={this.Count}: {nameof(SmallCollectionBenchmark)}");
4646

4747
this.MaxCount = this.Count;
4848
base.Setup();

source/Benchmarking/dotNetTips.Spargine.8.Benchmarking/TinyCollectionBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 02-27-2024
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-14-2024
7+
// Last Modified On : 01-31-2025
88
// ***********************************************************************
99
// <copyright file="TinyCollectionBenchmark.cs" company="David McCarter - dotNetTips.com">
1010
// McCarter Consulting (David McCarter)
@@ -35,15 +35,15 @@ public class TinyCollectionBenchmark : CollectionBenchmark
3535
/// Initializes a new instance of the <see cref="TinyCollectionBenchmark"/> class with a maximum count of 256.
3636
/// This constructor also logs the maximum count information using the <see cref="ConsoleLogger"/>.
3737
/// </summary>
38-
public TinyCollectionBenchmark() : base(256) => ConsoleLogger.Default.WriteLine(LogKind.Info, $"Max Count={this.MaxCount}: {nameof(TinyCollectionBenchmark)}.");
38+
public TinyCollectionBenchmark() : base(256) => LogInfo($"Max Count={this.MaxCount}: {nameof(TinyCollectionBenchmark)}.");
3939

4040
/// <summary>
4141
/// Performs setup operations specific to TinyCollectionBenchmark. This includes logging the current count before and after the base setup is called,
4242
/// and adjusting the MaxCount property to match the current Count. This method is called automatically by the BenchmarkDotNet framework before each benchmark run.
4343
/// </summary>
4444
public override void Setup()
4545
{
46-
ConsoleLogger.Default.WriteLine(LogKind.Info, $"Count={this.Count}: {nameof(TinyCollectionBenchmark)}");
46+
LogInfo($"Count={this.Count}: {nameof(TinyCollectionBenchmark)}");
4747

4848
this.MaxCount = this.Count;
4949
base.Setup();

0 commit comments

Comments
 (0)