Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating which recurring events happen in a date rang
Message
From
19/06/2010 13:28:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01469538
Message ID:
01469754
Views:
17
>>>Hi,
>>>Cool. But aren't you checking too many possible occurences. In SampleWithSingleEvent():
>>>int days = (new int[] { (end - e.StartDate).Days, 0 }).Max();
>>>//could be just?:
>>>int days = (end - e.StartDate).Days / e.RecurrenceDays;
>>>But still could be a lot of wasted calculations if the StartDate is way earlier than the range start ?
>>
>>While that is true I didn't go deeper to optimize it and trusted Linq's lazy evaluation. In real world applications likely day count would be less than 100 years * 366 = 36600 which is nothing to calculate for Linq. Range() is the cool method there providing a 'Tally table' where mortal T-SQL coders need to create themselves. Out of curiosity I just tested with 40000 days and on my old AMD Turion 64 MK-36 1 Gb RAM notebook it completes to create the dates list in 8-16 milliseconds.
>
>I'm sure you're right in that the processing time is minimal - but it still goes against the grain with me to waste a few milliseconds tho :-}
>Did you see my update? If I can get a range of maybe 10-12 instead of 40,000 I'd go for it.....

Yes now I saw and you are right:)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform