Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 3 additions & 13 deletions Ical.Net.Benchmarks/CalDateTimePerfTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright ical.net project maintainers and contributors.
// Licensed under the MIT license.
//
Expand All @@ -12,23 +12,13 @@ namespace Ical.Net.Benchmarks;
public class CalDateTimePerfTests
{
private const string _aTzid = "Australia/Sydney";
private const string _bTzid = "America/New_York";

[Benchmark]
public CalDateTime EmptyTzid() => CalDateTime.Now;

[Benchmark]
public CalDateTime SpecifiedTzid() => new CalDateTime(DateTime.Now, _aTzid);

[Benchmark]
public CalDateTime UtcDateTime() => new CalDateTime(DateTime.UtcNow);

[Benchmark]
public CalDateTime EmptyTzidToTzid() => EmptyTzid().ToTimeZone(_bTzid);

[Benchmark]
public CalDateTime SpecifiedTzidToDifferentTzid() => SpecifiedTzid().ToTimeZone(_bTzid);
public CalDateTime SpecifiedTzid() => CalDateTime.FromDateTime(DateTime.Now, _aTzid);

[Benchmark]
public CalDateTime UtcToDifferentTzid() => UtcDateTime().ToTimeZone(_bTzid);
public CalDateTime UtcDateTime() => CalDateTime.FromDateTime(DateTime.UtcNow);
}
32 changes: 16 additions & 16 deletions Ical.Net.Benchmarks/OccurencePerfTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright ical.net project maintainers and contributors.
// Licensed under the MIT license.
//
Expand Down Expand Up @@ -40,13 +40,13 @@ public void GetOccurrences()
public void MultipleEventsWithUntilOccurrencesSearchingByWholeCalendar()
{
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.InZoneLeniently(tz)
Expand All @@ -59,13 +59,13 @@ public void MultipleEventsWithUntilOccurrencesSearchingByWholeCalendar()
public void MultipleEventsWithUntilOccurrences()
{
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.InZoneLeniently(tz)
Expand All @@ -80,13 +80,13 @@ public void MultipleEventsWithUntilOccurrences()
public void MultipleEventsWithUntilOccurrencesEventsAsParallel()
{
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.PlusDays(10)
Expand Down Expand Up @@ -178,7 +178,7 @@ private static Calendar GetFourCalendarEventsWithUntilRule()
End = new(startTime.PlusMinutes(10), tzid),
RecurrenceRule = new(FrequencyType.Daily, 1)
{
Until = new(startTime.PlusDays(10).InUtc().ToInstant()),
Until = CalDateTime.FromZonedDateTime(startTime.PlusDays(10).InUtc()),
},
};
startTime = startTime.PlusDays(1);
Expand All @@ -195,13 +195,13 @@ public void MultipleEventsWithCountOccurrencesSearchingByWholeCalendar()
{
var calendar = GetFourCalendarEventsWithCountRule();
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.InZoneLeniently(tz)
Expand All @@ -215,13 +215,13 @@ public void MultipleEventsWithCountOccurrences()
{
var calendar = GetFourCalendarEventsWithCountRule();
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.InZoneLeniently(tz)
Expand All @@ -237,13 +237,13 @@ public void MultipleEventsWithCountOccurrencesEventsAsParallel()
{
var calendar = GetFourCalendarEventsWithCountRule();
var searchStart = _calendarFourEvents.Events.First().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(-1)
.InZoneLeniently(tz);

var searchEnd = _calendarFourEvents.Events.Last().DtStart!
.ToZonedDateTime(tz)
.ToZonedOrDefault(tz)
.LocalDateTime
.PlusYears(1)
.PlusDays(10)
Expand All @@ -270,8 +270,8 @@ private static Calendar GetFourCalendarEventsWithCountRule()
{
var e = new CalendarEvent
{
Start = new CalDateTime(startTime.AddMinutes(5), tzid),
End = new CalDateTime(startTime.AddMinutes(10), tzid),
Start = CalDateTime.FromDateTime(startTime.AddMinutes(5), tzid),
End = CalDateTime.FromDateTime(startTime.AddMinutes(10), tzid),
RecurrenceRule = new(FrequencyType.Daily, 1)
{
Count = 100,
Expand Down
6 changes: 3 additions & 3 deletions Ical.Net.Benchmarks/SerializationPerfTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright ical.net project maintainers and contributors.
// Licensed under the MIT license.
//
Expand Down Expand Up @@ -80,8 +80,8 @@ private static Calendar CreateSimpleCalendar()
var simpleCalendar = new Calendar();
var calendarEvent = new CalendarEvent
{
Start = new CalDateTime(DateTime.Now, timeZoneId),
End = new CalDateTime(DateTime.Now + TimeSpan.FromHours(1), timeZoneId),
Start = CalDateTime.FromDateTime(DateTime.Now, timeZoneId),
End = CalDateTime.FromDateTime(DateTime.Now + TimeSpan.FromHours(1), timeZoneId),
RecurrenceRule = new(FrequencyType.Daily, 1)
{
Count = 100,
Expand Down
Loading
Loading