Let's say I have a List
, with PageHit having these properties: <PageHit
>DateTime RequestTime
and int PageResponseTime
.
Ultimately what I'm trying to do is to round each RequestTime value to the nearest 30 minute increment (using How can I round up the time to the nearest X minutes?), group them together, and get the overall average of PageResponseTime for that increment block (real world user story: track the average page response time per 30 minute block).
This is as far as I've gotten, but my brain won't immediately show me how to efficiently get the average for each increment without some gross loop. Is there a way to do this in Step 1?
// Step 1: round all request times up
pageHitList.ForEach(x => x.RequestTime = x.RequestTime.RoundUp(TimeSpan.FromMinutes(30));
// Step 2: Get the average of each increment block
?