A simple business indicator tool that uses a sliding window to detect whether the indicator exceeds the threshold

Related tags

Utilities melon
Overview

melon

A simple business indicator tool that uses a sliding window to detect whether the indicator exceeds the threshold

Usage

//create the metric
//the ring length is 5000, greater is better for the accuracy compute, it can be equal to instance qps
// if 18 bad in latest 20 point, it return false
// if 70 bad in latest 100 point, the same to above.
me := melon.New(5000, OptionAnchor(20, 18), OptionAnchor(100, 70))

//set metric like below:
//if everything ok
me.Feed(true)
//if something wrong
me.Feed(false)

//get metric health stat
if me.OK() {
   //it means that your system is health
} else {
   //todo some repair
}

Benchmark

on 4core8G machine, windows system.

1.benchmark feed

//function
func BenchmarkMelonFeed(b *testing.B) {
	me := New(5000, OptionAnchor(100, 70))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		if i%10 == 0 {
			me.Feed(true)
		} else {
			me.Feed(false)
		}
	}
}

//result:
goos: windows
goarch: amd64
pkg: github.com/alwaysthanks/melon
BenchmarkMelonFeed-4   	50000000	        28.6 ns/op
PASS

2.benchmark OK

func BenchmarkMelonOK(b *testing.B) {
	me := New(5000, OptionAnchor(100, 70))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		me.OK()
	}
}

//result:
goos: windows
goarch: amd64
pkg: github.com/alwaysthanks/melon
BenchmarkMelonOk-4   	 1000000	      1095 ns/op
PASS
You might also like...
Simple arc-dps utililty tool

arc-dps-launcher The base idea of this project is to provide a simple method of updating the GuildWars2 tool arcdps, a gw2 dps meter (and general comb

Go-generics-simple-doubly-linked-list - A simple doubly linked list implemented using generics (Golang)

Welcome to Go-Generics-Simple-Doubly-Linked-List! Hi, This repository contains a

efaceconv - Code generation tool for high performance conversion from interface{} to immutable type without allocations.

efaceconv High performance conversion from interface{} to immutable types without additional allocations This is tool for go generate and common lib (

GoWrap is a command line tool for generating decorators for Go interfaces

GoWrap GoWrap is a command line tool that generates decorators for Go interface types using simple templates. With GoWrap you can easily add metrics,

Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

a tool for creating exploited media files for discord

Discord-Exploits A program for creating exploited media files for discord written in Go. Usage discord-exploits is a command line utility, meaning you

A full-featured license tool to check and fix license headers and resolve dependencies' licenses.
A full-featured license tool to check and fix license headers and resolve dependencies' licenses.

SkyWalking Eyes A full-featured license tool to check and fix license headers and resolve dependencies' licenses. Usage You can use License-Eye in Git

sigurls is a reconnaissance tool, it fetches URLs from AlienVault's OTX, Common Crawl, URLScan, Github and the Wayback Machine.

sigurls is a reconnaissance tool, it fetches URLs from AlienVault's OTX, Common Crawl, URLScan, Github and the Wayback Machine. DiSCLAIMER: fe

A tool and library for using structural regular expressions.

Structural Regular Expressions sregx is a package and tool for using structural regular expressions as described by Rob Pike (link).

Owner
believe
believe
Scalable golang ratelimiter using the sliding window algorithm. Currently supports only Redis.

go-ratelimiter Scalable golang ratelimiter using the sliding window algorithm. Currently supports only Redis. Example usage client := redis.NewClient

null 0 Oct 19, 2021
Sliding window counters Redis rate limiting implementation for Golang

Sliding window counters Redis rate limiting implementation for Golang (Based on the Figma API rate limit algorithm)

Barnaby Keene 6 Dec 21, 2022
redis-util business-friendly encapsulation of redis operations, such as the common cache set get operation

redis-util 方便业务使用的redis操作封装,比如常见的缓存set get操作, 一行代码搞定,不像开源库需要写好多行 使用方法

connor 1 Oct 22, 2021
流媒体NetFlix解锁检测脚本 / A script used to determine whether your network can watch native Netflix movies or not

netflix-verify 流媒体NetFlix解锁检测脚本,使用Go语言编写 在VPS网络正常的情况下,哪怕是双栈网络也可在几秒内快速完成IPv4/IPv6的解锁判断 鸣谢 感谢 @CoiaPrant 指出对于地域检测更简便的方法 感谢 @XmJwit 解决了IPV6 Only VPS无法下载脚

null 2k Dec 29, 2022
This is a Pub/Sub for the Watermill project which uses the Bolt database.

Watermill Bolt Pub/Sub This is a Pub/Sub for the Watermill project which uses the Bolt database.

Three Dots Labs 6 Jun 13, 2022
Utility library that uses Go generics mechanism

golang-generics-util Utility library that explores Go generics (1.18) xsync Sync

Anton Tiurin 4 Dec 11, 2022
JIN the coolest fighting game ever made that uses the M.U.G.E.N engine so heres how you can build it

JIN the coolest fighting game ever made that uses the M.U.G.E.N engine so heres how you can build it

Elijah Davis 1 Jan 24, 2022
A simple tool to auto remove unused imports in rust

rust_strip A simple tool to remove unused imports in RUST. Call Cargo build/test Process the warning logs of unused imports Then replace the involved

sundyli 7 Oct 15, 2022
Payload is a simple tool for working with production data in your local environment.

Payload Payload is a simple tool for working with production data in your local environment. What problem does it solve? You're working with Cloud SQL

Ivan Vanderbyl 1 Oct 13, 2021
Serial-locate - A simple tool for searching the COM port

serial-locate A simple tool for searching the COM port Usage Direct query serial

Dirk Arnez 0 Jan 18, 2022