<commit_before>package stats

import (
	"sync/atomic"
	"time"
)

type Gauge64 struct {
	val uint64
}

func NewGauge64(name string) *Gauge64 {
	return registry.getOrAdd(name, &Gauge64{}).(*Gauge64)
}

func (g *Gauge64) Inc() {
	atomic.AddUint64(&g.val, 1)
}

func (g *Gauge64) Dec() {
	atomic.AddUint64(&g.val, ^uint64(0))
}

func (g *Gauge64) AddUint64(val uint64) {
	atomic.AddUint64(&g.val, val)
}

func (g *Gauge64) DecUint64(val uint64) {
	atomic.AddUint64(&g.val, ^uint64(val-1))
}

func (g *Gauge64) Add(val int) {
	if val == 0 {
		return
	}
	if val > 0 {
		g.AddUint64(uint64(val))
		return
	}
	// < 0
	g.DecUint64(uint64(-1 * val))
}

func (g *Gauge64) Set(val int) {
	atomic.StoreUint64(&g.val, uint64(val))
}

func (g *Gauge64) SetUint64(val uint64) {
	atomic.StoreUint64(&g.val, val)
}

func (g *Gauge64) ReportGraphite(prefix, buf []byte, now time.Time) []byte {
	val := atomic.LoadUint64(&g.val)
	buf = WriteUint64(buf, prefix, []byte("gauge64"), val, now)
	return buf
}

func (c *Gauge64) Peek() uint64 {
	return atomic.LoadUint64(&c.val)
}
<commit_msg>type alias stats.Gauge64 to uint64, which is what it is<commit_after>package stats

import (
	"sync/atomic"
	"time"
)

type Gauge64 uint64

func NewGauge64(name string) *Gauge64 {
	u := Gauge64(0)
	return registry.getOrAdd(name, &u).(*Gauge64)
}

func NewGauge64Existing(name string, g *Gauge64) *Gauge64 {
	return registry.getOrAdd(name, g).(*Gauge64)
}

func (g *Gauge64) Inc() {
	atomic.AddUint64((*uint64)(g), 1)
}

func (g *Gauge64) Dec() {
	atomic.AddUint64((*uint64)(g), ^uint64(0))
}

func (g *Gauge64) AddUint64(val uint64) {
	atomic.AddUint64((*uint64)(g), val)
}

func (g *Gauge64) DecUint64(val uint64) {
	atomic.AddUint64((*uint64)(g), ^uint64(val-1))
}

func (g *Gauge64) Add(val int) {
	if val == 0 {
		return
	}
	if val > 0 {
		g.AddUint64(uint64(val))
		return
	}
	// < 0
	g.DecUint64(uint64(-1 * val))
}

func (g *Gauge64) Set(val int) {
	atomic.StoreUint64((*uint64)(g), uint64(val))
}

func (g *Gauge64) SetUint64(val uint64) {
	atomic.StoreUint64((*uint64)(g), val)
}

func (g *Gauge64) ReportGraphite(prefix, buf []byte, now time.Time) []byte {
	val := atomic.LoadUint64((*uint64)(g))
	buf = WriteUint64(buf, prefix, []byte("gauge64"), val, now)
	return buf
}

func (g *Gauge64) Peek() uint64 {
	return atomic.LoadUint64((*uint64)(g))
}

{'fraction_non_alphanumeric': 0.1809974204643164, 'fraction_numerical': 0.08555460017196904, 'mean_word_length': 4.607228915662651, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2308642', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1015, 'n_words': 218}