I am delighted to announce the release of Spargine 8 (v2025.8.8.6) on August 6th, 2025. Spargine, my open-source project, now offers NuGet packages for .NET 8 & 9. These enhancements have been integrated across all my projects, many of which are currently in production. I encourage you to explore these updates and share any feedback or suggestions for further improvements.
This update introduces new classes, methods, benchmarks, and comprehensive unit tests, all aimed at improving Spargine’s performance and reliability! Notably, this release includes speed enhancements informed by benchmark tests outlined in the 4th edition of Rock Your Code: Code & App Performance for Microsoft .NET, available on Amazon.
GitHub: https://github.com/RealDotNetDave/dotNetTips.Spargine.8/releases
NuGet: http://bit.ly/dotNetDaveNuGet
You can access all the performance data for these assemblies on GitHub. I continually seek assistance with these projects. If you are interested in contributing, please don’t hesitate to contact me via email at dotnetdave@live.com. Your support and collaboration are highly appreciated!
Note: This will be the final major update for Spargine 8. After the release, my focus will shift to releasing the .NET 10 version. I am genuinely excited to explore what the new version will bring, particularly in terms of performance enhancements. The future looks bright!
PerformanceStopwatch Enhancements
The PerformanceStopwatch type has been significantly enhanced to support deeper diagnostics and event-driven tracking—making it an essential tool for accurately capturing code execution time.
New Events:
- EventHandler<ElapsedEventArgs>? ResetCompleted: Triggered when the stopwatch is reset.
- EventHandler<ElapsedEventArgs>? StoppedCompleted: Triggered when the stopwatch is stopped.
- EventHandler<ElapsedEventArgs>? ThresholdExceeded: Triggered when the elapsed time exceeds a specified threshold.
New Methods:
- ClearLaps(): Clears all recorded lap times.
- ExportToJson(): Serializes stopwatch data—including laps and diagnostics—to JSON.
- ReadOnlyCollection<string> GetDiagnosticMessages(): Retrieves all recorded diagnostic messages.
- GetElapsedTimeString(): Returns the formatted current elapsed time as a string.
- GetLaps(): Gets a read-only list of all lap times.
- LogMessage(ILogger logger, string message): Logs a custom message with the current elapsed time.
- RecordLap(): Records a lap (checkpoint).
- StartNewWithAlertThreshold(TimeSpan? alertThreshold, string title): Starts a new stopwatch with an alert threshold and optional title.
- StartNewWithTelemetry(TelemetryClient telemetry, string operationName, TimeSpan? alertThreshold, string message, IDictionary<string, string>? properties): Starts the stopwatch with Application Insights telemetry support.
- StopIfThresholdExceeded(): Stops the stopwatch if the elapsed time exceeds the defined threshold.
- TrackTelemetry(TelemetryClient telemetry, string operationName, string message, IDictionary<string, string>? properties): Sends telemetry data for the current stopwatch instance.
New Property:
- IsThresholdExceeded: Indicates whether the elapsed time has surpassed the configured threshold.
New Type: DiagnosticEntry
To complement the enhanced PerformanceStopwatch, the DiagnosticEntry struct was introduced to improve diagnostic reporting.
Constructor:
- DiagnosticEntry(DateTimeOffset timestamp, string message, TimeSpan elapsed): Initializes with a UTC timestamp, a diagnostic message, and the recorded elapsed time.
Properties:
- Timestamp: The UTC timestamp of the diagnostic entry.
- Message: The content of the diagnostic message.
- Elapsed: The elapsed time at the time the entry was recorded.
Method:
- ToString(): Returns a human-readable string with the timestamp, message, and elapsed time in milliseconds.
New Type: ElapsedEventArgs
This class supports the new stopwatch events by providing relevant event data.
Constructor:
- ElapsedEventArgs(TimeSpan elapsed): Initializes a new instance with the specified elapsed time.
Property:
- Elapsed: Gets the elapsed time value.
Summary
These new and enhanced features in Spargine are designed to help you write faster, more reliable, and more maintainable applications. Detailed benchmark results are available on GitHub for those who want to dig deeper into performance improvements.
As always, the continued success of Spargine depends on the support and involvement of the developer community. If you’ve found these updates useful—or if you have ideas for improvements—I encourage you to get involved:
- Submit a pull request
- Report an issue
- Suggest new features
Every contribution matters.
Be sure to register at dotNetTips.com to get notified when the .NET 10 version is released. I plan to publish it as soon as possible following the official launch of .NET 10 in November.
Together, we can continue to make Spargine a robust and indispensable toolkit for the .NET ecosystem. Your feedback and support are always appreciated—please share your thoughts in the comments.
Thank you for your support, and keep coding faster and better!
Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave
© The information in this article is copywritten and cannot be reproduced in any way without express permission from David McCarter.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
