Documentation ¶
Index ¶
- Constants
- func CreateDir(path string) error
- func GetHostName() (string, error)
- func GetNowMs() int64
- func IsNil(i interface{}) bool
- func MurmurHash64A(data []byte) (h uint64)
- func Write(strs ...string) (string, error)
- type Cell
- type SlidingWindow
- func (sw *SlidingWindow) GetActualDurationMs(nowMs int64) int64
- func (sw *SlidingWindow) GetHit(nowMs int64, metricName string) int64
- func (sw *SlidingWindow) GetHits(nowMs int64, metricNames ...string) map[string]int64
- func (sw *SlidingWindow) GetNowHits(nowMs int64, metricNames ...string) map[string]int64
- func (sw *SlidingWindow) Hit(nowMs int64, metricNames ...string)
Constants ¶
const ( BIG_M = 0xc6a4a7935bd1e995 BIG_R = 47 SEED = 0x1234ABCD )
Variables ¶
This section is empty.
Functions ¶
func GetHostName ¶
func MurmurHash64A ¶
murmur hash function. When the number of unique elements is 10000000, the hash distribution is as follows: |--------------------||--------------------| | bucket | num || bucket | num | |--------------------||--------------------| | 0 | 1000095 || 5 | 999697 | |--------------------||--------------------| | 1 | 1000449 || 6 | 1000249 | |--------------------||--------------------| | 2 | 999580 || 7 | 1000917 | |--------------------||--------------------| | 3 | 999182 || 8 | 1000388 | |--------------------||--------------------| | 4 | 998817 || 9 | 1000626 | |--------------------||--------------------|
E(X) = 389275.8
Types ¶
type SlidingWindow ¶
type SlidingWindow struct { Size int64 CellIntervalMs int64 Cells []*Cell // invariant: len(Cells) == Size. }
func NewSlidingWindow ¶
func NewSlidingWindow(size int64, cellIntervalMs int64) *SlidingWindow
func (*SlidingWindow) GetActualDurationMs ¶
func (sw *SlidingWindow) GetActualDurationMs(nowMs int64) int64
func (*SlidingWindow) GetHit ¶
func (sw *SlidingWindow) GetHit(nowMs int64, metricName string) int64
func (*SlidingWindow) GetHits ¶
func (sw *SlidingWindow) GetHits(nowMs int64, metricNames ...string) map[string]int64
func (*SlidingWindow) GetNowHits ¶
func (sw *SlidingWindow) GetNowHits(nowMs int64, metricNames ...string) map[string]int64
func (*SlidingWindow) Hit ¶
func (sw *SlidingWindow) Hit(nowMs int64, metricNames ...string)
一次动作(如请求),记为一次 Hit。