4 ms·
Does anyone know a good answer for the RealTimeCounter question?
by scotth 13y ago
Does anyone know a good answer for the RealTimeCounter question?
- guard-of-terra 13y ago- have a counter for every bigger interval asnd the last timestamp If the timestamp is same second as last increment everything, if not increment where appropriate and rotate everything else to 0. What am i missing?
- scotth 13y agoMy reading of the API is that getCountInLastSecond returns the count from the last billion nanoseconds, not the count from the previous second bucket (as the clock ticks). So when he mentions he can't bound memory, it's because he can't easily discretize the counters.
- rlpb 13y agoI feel that this is an important ambiguity. When I read the article, my first question was whether this interpretation is correct, or the other one. I am surprised that he didn't clarify this in the article, and wonder if this is a problem. Seeing ambiguities in specifications is an important part of software engineering.
- scotth 13y agoI think you're right. Note taken.
- reikonomusha 13y agoThis is the correct interpretation. Imagine an infinite time line, with a marker moving across the line at the speed of time. Every time increment is called, that marker is saved on the timeline. When getCountInLastX is called, one must return the number of marks on the timeline from the current time to the current time minus X.
- guard-of-terra 13y agoThen you also need to carry a second-worth of timestamps in a queue.
- deleted 13y ago[deleted]