-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarks for
DateOnly
, TimeOnly
and DateTimeOffset
- Loading branch information
Showing
6 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Benchmarks/aweXpect..Chronology.Benchmarks/HappyCaseBenchmarks.DateOnly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#if NET8_0_OR_GREATER | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace aweXpect.Chronology.Benchmarks; | ||
|
||
public partial class HappyCaseBenchmarks | ||
{ | ||
[Benchmark] | ||
public DateOnly DateOnly_aweXpect() | ||
=> _day.July(_year); | ||
|
||
[Benchmark] | ||
public DateOnly DateOnly_DotNet() | ||
=> new(_year, _month, _day); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Benchmarks/aweXpect..Chronology.Benchmarks/HappyCaseBenchmarks.DateTimeOffset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace aweXpect.Chronology.Benchmarks; | ||
|
||
public partial class HappyCaseBenchmarks | ||
{ | ||
[Benchmark] | ||
public DateTimeOffset DateTimeOffset_aweXpect() | ||
=> _day.July(_year).At(_hour, _minute, _second).WithOffset(2.Hours()); | ||
|
||
[Benchmark] | ||
public DateTimeOffset DateTimeOffset_DotNet() | ||
=> new(_year, _month, _day, _hour, _minute, _second, TimeSpan.FromHours(2)); | ||
} |
16 changes: 16 additions & 0 deletions
16
Benchmarks/aweXpect..Chronology.Benchmarks/HappyCaseBenchmarks.TimeOnly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#if NET8_0_OR_GREATER | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace aweXpect.Chronology.Benchmarks; | ||
|
||
public partial class HappyCaseBenchmarks | ||
{ | ||
[Benchmark] | ||
public TimeOnly TimeOnly_aweXpect() | ||
=> _hour.Hours(_minute.Minutes(_second.Seconds())); | ||
|
||
[Benchmark] | ||
public TimeOnly TimeOnly_DotNet() | ||
=> TimeOnly.FromTimeSpan(new TimeSpan(_hour, _minute, _second)); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters