When working with .NET, developers can obtain the initiating process ID using either Process.GetCurrentProcess().Id or System.Environment.ProcessId. Benchmark tests show that the former is slightly more performant. Additionally, the setup for this is specified in EditorConfig as a suggestion for code quality.
Category: .NET
General Performance Tip: Handling Exceptions
In my presentation at the Silicon Valley Code Camp, a question about the performance of using the When() clause for catching exceptions prompted me to conduct performance testing. While traditional exception handling is crucial, my testing revealed that the When() clause is more performant when capturing multiple similar exceptions.
Speed up LINQ Any() with Spargine FastAny()
The article introduces FastAny(), a method in the DotNetTips.Spargine.Extensions NuGet package designed to accelerate LINQ's Any() call, showcasing a 1.08 times performance improvement over the standard method. Notably, FastAny() not only enhances speed but also includes a built-in null check for the collection.
Collection Performance: Comparing ImmutableArray<>’s with SequenceEqual()
The ImmutableArrayExtensions contain a SequenceEqual() method for comparing ImmutableArray items. The method compares elements using the default equality comparer for TSource and can be used with a for() loop for performance validation.
General Performance Tip: Comparing ComputeHash(), HashData(), and TryHashData() Methods
Developers can simplify hashing byte arrays by using HashData() instead of ComputeHash(), as it requires less code and eliminates the need to manage the SHA256 object. Benchmarking shows HashData() is about 1.16x faster than ComputeHash() and 1.02x faster than TryHashData(). EditorConfig helps manage related diagnostics.
General Performance Tip: Creating an Object
In this investigation of object creation in .NET, various methods were explored, including "new" keyword, Activator.CreateInstance, and RuntimeHelpers.GetUninitializedObject.
Speed up Logging with Spargine FastLogger
FastLogger in DotNetTips.Spargine.Core offers a simple solution to accelerate logging in applications, providing over 5 times better performance, as showcased in benchmark results. The use of source generators further emphasizes the efficiency gains achievable in code optimization.
Unveiling Spargine 8: A Comprehensive Guide to .NET 8 Integration and Exciting Feature Updates
The article announces the release of Spargine 8, a .NET 8 integrated version with updated NuGet packages. The comprehensive guide highlights new features, including a method for real-time file copying progress, additional functionalities in core, extensions, and tester libraries, along with significant transformations and breaking modifications, urging users to transition to the enhanced version for improved performance.
dotNetDave Rocks Warsaw IT Days 2024
I'm excited to announce that, for the first time ever, the For Those About To Code: World Wide Tour will be making a virtual stop at the 2024 Warsaw IT Days event in Warsaw, Poland, taking place from April 5th to 6th!
General Performance Tip: Avoid Unnecessary Variable Initialization
In the analysis of code, it's noted that explicit initialization of variables, when the default state is already set, can impact performance. Situations requiring variable initialization are discussed, with examples showing unnecessary explicit initialization. The default values for reference types and the default values for properties of a custom type are also examined.

You must be logged in to post a comment.