Smalltalk/X WebserverDocumentation of class 'AbstractAnnealingCounter': | |
Class: AbstractAnnealingCounterInheritance:Object | +--AbstractAnnealingCounter | +--AnnealingCounter
Description:a counter which decays over time; useful to measure (i.e. count) events and give recent events more weight than older ones. For example, to measure hot spots in code, by counting calls (where we want to forget old calls) for profilers or to implement better LRU algorithms. The counter decays older events at a rate of decayRate per timeInterval. Notice: The standard AnnealingCounter has per-instance configurable rate and interval, which may use up too much memory if you need many (zillions) of them. In that case, make a subclass, which provides those from a constant (class variable or getter). Redefinable: decayRate eg. 0.5 timeInterval eg. 1 seconds now eg. Timestamp now For example, to use simulated clock ticks, redefine >>timeInterval to return the integer 1, and >>now to return whatever your (simulated clock) tick is. Class protocol:defaults instance creation
Instance protocol:accessing accessing-behavior
Examples:a counter which decays to 1/2 every second; measure an event at t=1, t=5 and t=6, and fetch its value at t=7. |cnt| cnt := AnnealingCounter new. cnt decayRate:0.5. Delay waitForSeconds:1. cnt increment. Delay waitForSeconds:4. cnt increment. Delay waitForSeconds:1. cnt increment. Delay waitForSeconds:1. cnt value. |
|
ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:16:14 GMT |