All Projects → orian → counters

orian / counters

Licence: MIT license
A GoLang implementation of counters.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to counters

CSGO-Offset-Scanner
Java Based Cross-Platform CSGO Offset and Netvar Scanner
Stars: ✭ 28 (+86.67%)
Mutual labels:  counter
Image-Support
Add badge with counter to ImageView Android.
Stars: ✭ 128 (+753.33%)
Mutual labels:  counter
firehose
firehose: the metrics gateway for prometheus
Stars: ✭ 23 (+53.33%)
Mutual labels:  metrics-gathering
laravel-counters
Counters Management for laravel project.
Stars: ✭ 43 (+186.67%)
Mutual labels:  counter
hass-variables
Home Assistant variables component
Stars: ✭ 35 (+133.33%)
Mutual labels:  counter
redis-metrics
Easy metric tracking and aggregation using Redis
Stars: ✭ 29 (+93.33%)
Mutual labels:  counter
Unity-FPS-Counter
#NVJOB FPS Counter and Graph. Free Unity Asset.
Stars: ✭ 44 (+193.33%)
Mutual labels:  counter
tm
timers and timeline
Stars: ✭ 31 (+106.67%)
Mutual labels:  counter
django-redirects
↪️ ✅ redirects as they should be, with full control.
Stars: ✭ 32 (+113.33%)
Mutual labels:  counter
inspector-metrics
Typescript metrics / monitoring library
Stars: ✭ 19 (+26.67%)
Mutual labels:  counter
textics
📉 JavaScript Text Statistics that counts lines, words, chars, and spaces.
Stars: ✭ 36 (+140%)
Mutual labels:  counter
telegram-counter-bot
A simple, easy to use counter bot to keep track of all the amazing things in your Telegram group!
Stars: ✭ 29 (+93.33%)
Mutual labels:  counter
ios-application
A native, lightweight and secure one-time-password (OTP) client built for iOS; Raivo OTP!
Stars: ✭ 581 (+3773.33%)
Mutual labels:  counter
performance-counters
Extremely useful library for collecting and tracking performance metrics in your .NET application
Stars: ✭ 16 (+6.67%)
Mutual labels:  counter
pageviews
A simple and lightweight pageviews counter for your WordPress posts and pages.
Stars: ✭ 23 (+53.33%)
Mutual labels:  counter
vue-countable
✍️ Vue binding for countable.js. Provides real-time paragraph, sentence, word, and character counting.
Stars: ✭ 25 (+66.67%)
Mutual labels:  counter
API
API for SQLMatches.
Stars: ✭ 48 (+220%)
Mutual labels:  counter
commonpp
Small library helping you with basic stuff like getting metrics out of your code, thread naming, etc.
Stars: ✭ 29 (+93.33%)
Mutual labels:  counter
go-sensor
🚀 Go Distributed Tracing & Metrics Sensor for Instana
Stars: ✭ 90 (+500%)
Mutual labels:  metrics-gathering
CounterView
一个数字变化效果的计数器视图控件
Stars: ✭ 38 (+153.33%)
Mutual labels:  counter

counters

A GoLang implementation of counters.

It provides an object: counters.CounterBox and Counter, Min and Max implementation.

Installation:

$ go get -u github.com/orian/counters

The example usages:

import "github.com/orian/counters"

//... some code

cb := counters.NewCounterBox()
c := cb.GetCounter("ex")
c.Increment()
c.IncrementBy(6)
c.Value()  // returns 7
cb.GetCounter("ex").Value()  // Returns 7

For convenience there is also an http.HandleFunc provided which prints values of counters.

One may use subpackage globals if want to use a global counters.

import "github.com/orian/counters/global"

//... some code

c := global.GetCounter("ex")
c.Increment()
c.IncrementBy(6)
c.Value()  // returns 7
global.GetCounter("ex").Value()  // Returns 7

The library and all objects are thread safe.

Print into log or stdout on SIGINT

Please check the example/example.go to see how the interrupt can be handled in a nice way.

Performance and benchmarks

The library has two benchmarks. It's blazingly fast. One should cache counters which are used often. Every time the counter is requested, it's necessary to look up in map for a counter, this slows down the lib by a factor of 4.

$ go test --bench=. .
PASS
BenchmarkCounters        1000000      1287 ns/op
BenchmarkCountersCached  5000000       252 ns/op
ok      github.com/orian/counters   2.822s
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].