Skip to content

Using BenchmarkDotNet, we compare the performance of these methods on .NET 6.0 and .NET 8.0.

Notifications You must be signed in to change notification settings

omertayhan/BenchmarkDotNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BenchmarkDotNet

This repository contains benchmarks for various methods of extracting the year from a DateTime string in .NET. The benchmarks are implemented using BenchmarkDotNet and target both .NET 6.0 and .NET 8.0 to compare performance across different runtime versions.

Benchmark Methods

The following methods are benchmarked to extract the year from a DateTime string:

  • GetYearFromDate(): Parses the entire DateTime string using DateTime.Parse and returns the year.
  • GetYearFromSplit(): Splits the DateTime string by the '-' character and parses the year.
  • GetYearFromSubStr(): Uses Substring to extract the year part from the DateTime string and parses it.
  • GetYearFromSpan(): Utilizes ReadOnlySpan<char> to slice the DateTime string and manually converts the year part to an integer.
  • GetYearFromSpanWithManualConversion(): Uses ReadOnlySpan<char> to slice the DateTime string and converts the year part using int.Parse.

Project Setup

Ensure you have .NET 6.0 and .NET 8.0 SDKs installed. You can check installed SDKs using:

dotnet --list-sdks

Clone the repository:

git clone https://github.com/omertayhan/BenchmarkDotNet.git
cd BenchmarkDotNet

Restore the dependencies:

dotnet restore

Run the benchmarks:

dotnet run -c Release

Sample Output BenchmarkDotNet will output the benchmark results, comparing the performance of each method across .NET 6.0 and .NET 8.0. The results will include metrics such as mean execution time, memory usage, and more.

1

About

Using BenchmarkDotNet, we compare the performance of these methods on .NET 6.0 and .NET 8.0.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages