General Performance Tip: Generating Random Numbers
DotNetTips Blog
by dotNetDave
11h ago
NET's Random type has been a popular choice for generating random numbers. However, using RandomNumberGenerator for this purpose can result in a six-fold performance improvement, as shown in benchmark tests. Both methods allocate the same amount of memory ..read more
Visit website
Speed up Empty String Validation with Spargine
DotNetTips Blog
by dotNetDave
11h ago
The article introduces two methods, IsEmpty() and IsNotEmpty(), for validating empty strings in Spargine, comparing them to the IsNullOrEmpty() method in .NET and emphasizing their straightforward usage and ability to handle null checks. Benchmark results reveal that IsEmpty() surpasses IsNullOrEmpty() in performance, exhibiting a 2.92 times faster execution speed ..read more
Visit website
Seamless Method Relocation: A Proposal for Visual Studio Refactoring
DotNetTips Blog
by dotNetDave
3d ago
"Proposing a new refactoring feature for Visual Studio, this article suggests seamlessly relocating methods alongside associated code to new or existing classes. By automating this process, developers can streamline workflow, reduce manual effort, and enhance productivity ..read more
Visit website
Code It Any Way You Want: Performance of Out Variable Declaration
DotNetTips Blog
by dotNetDave
3d ago
Starting with .NET 7, it's recommended to inline variable declarations when using methods with out parameters for improved performance and readability, as demonstrated in the article. This practice not only enhances code maintainability and readability but also showcases slight performance improvements based on benchmark tests conducted ..read more
Visit website
Collection Performance: Using ForEachAsync() with List<>
DotNetTips Blog
by dotNetDave
5d ago
The post demonstrates the usage of Parallel.ForEachAsync() with a List of reference types ..read more
Visit website
Code It Any Way You Want: Exploring Thread Id Retrieval Methods
DotNetTips Blog
by dotNetDave
5d ago
Exploring Thread ID Retrieval Methods There are two ways to get the ID of the current thread. One way is to use the Thread class, as shown in this example: var id = Thread.CurrentThread.ManagedThreadId The thread ID can also be retrieved using System.Environment.CurrentManagedThreadId, as shown in this example: var id = System.Environment.CurrentManagedThreadId Benchmark Results As seen in the results below, the performance of these two methods to obtain the current thread ID is nearly identical, and both methods allocate zero bytes in memory ..read more
Visit website
Rockin’ the Code World Season 4: Special Guest Mark Brown
DotNetTips Blog
by dotNetDave
1w ago
Join Mark Brown and I live on April 6th, 2024 at 10:00 PST for the 100th episode of our show, where we'll be delving into the exciting topic of building generative AI applications with Microsoft .NET. Get ready for a fun and informative discussion ..read more
Visit website
General Performance Tip: Logging
DotNetTips Blog
by dotNetDave
1w ago
Recently, an enhanced logging method for .NET 6 was added, outperforming the existing approach. This utilizes a source generator to integrate LoggerMessageAttribute for improved logging performance. Resulting benchmark demonstrated up to an 11x improvement in performance. The method is crucial in cloud environments and for identifying code issues. For more details, refer to the Faster Performance with DotNetTips.Spargine chapter ..read more
Visit website
Optimizing String Concatenation in C# with Spargine FastStringBuilder
DotNetTips Blog
by dotNetDave
1w ago
Explore enhanced string concatenation in C# programming with the FastStringBuilder from DotNetTips.Spargine.Core, utilizing the ConcatStrings() method for optimized performance. Benchmark results reveal a 1.107 times performance improvement and reduced memory allocations, making it a valuable tool for efficient string manipulation ..read more
Visit website
General Performance Tip: Retrieving the Process Id
DotNetTips Blog
by dotNetDave
2w ago
When working with .NET, there are two options to obtain the initiating process ID. The Process type and System.Environment both provide methods for this. Benchmark tests reveal that using the ProcessId property is 87.44 times more efficient, without memory allocation ..read more
Visit website

Follow DotNetTips Blog on FeedSpot

Continue with Google
Continue with Apple
OR