Skip to content

Benchmarks for DateTime.Day/.Month/.Year/.DayOfYear #2549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/benchmarks/micro/libraries/System.Runtime/Perf.DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Perf_DateTime
{
DateTime date1 = new DateTime(1996, 6, 3, 22, 15, 0);
DateTime date2 = new DateTime(1996, 12, 6, 13, 2, 0);

[Benchmark]
public DateTime GetNow() => DateTime.Now;

Expand Down Expand Up @@ -41,5 +41,17 @@ public static IEnumerable<string> ToString_MemberData()

[Benchmark]
public DateTime ParseO() => DateTime.ParseExact("1996-06-03T22:15:00.0000000", "o", null);

[Benchmark]
public int Day() => date1.Day;

[Benchmark]
public int Month() => date1.Month;

[Benchmark]
public int Year() => date1.Year;

[Benchmark]
public int DayOfYear() => date1.DayOfYear;
}
}