4 ms·
Is there some possible optimization to be made here by bucketing seconds and dropping buckets wholesale rather than having to peel off items until you find the
by tobz 11y ago
Is there some possible optimization to be made here by bucketing seconds and dropping buckets wholesale rather than having to peel off items until you find the start of the window?
You'd end up quantizing the window, but.. dunno, just spitballing here.
- Stratus3D 11y agoI had thought about that but never got around to building a sliding window that worked that way. The challenge is that then the `events/0` call might return events outside the window of time. But there is a potential performance improvement if we don't have to always be removing old events one by one. I'll have to try improving the list implementation with "buckets"... I wonder if buckets could be represented as lists stored inside a tuple or another list...
- tobz 11y agoRight, you'd end up returning one bucket too little, or one bucket too much, of your full time window, depending on what tradeoff you decided was OK to have. And yeah, I was thinking of buckets as append-only lists that got dropped in their entirety when out of range.