<commit_before>package metric_test

import (
	"runtime"
	"sync"

	. "github.com/concourse/atc/metric"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Counter", func() {
	var counter *Counter

	BeforeEach(func() {
		counter = &Counter{}
	})

	It("tracks the maximum value seen since last checked", func() {
		counter.Inc()
		counter.Inc()
		counter.Dec()

		Expect(counter.Max()).To(Equal(int64(2)))
	})

	It("deals with concurrent increments correctly", func() {
		// buckle up
		defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU()))

		totalIncs := 30
		wg := new(sync.WaitGroup)
		wg.Add(totalIncs)

		for i := 0; i < totalIncs; i++ {
			go func() {
				counter.Inc()
				wg.Done()
			}()
		}

		wg.Wait()

		Expect(counter.Max()).To(Equal(int64(totalIncs)))
	})

	It("resets the max to the current value when observed", func() {
		counter.Inc()
		counter.Inc()
		counter.Dec()

		Expect(counter.Max()).To(Equal(int64(2)))

		Expect(counter.Max()).To(Equal(int64(1)))
	})
})
<commit_msg>woops, fix types<commit_after>package metric_test

import (
	"runtime"
	"sync"

	. "github.com/concourse/atc/metric"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Counter", func() {
	var counter *Counter

	BeforeEach(func() {
		counter = &Counter{}
	})

	It("tracks the maximum value seen since last checked", func() {
		counter.Inc()
		counter.Inc()
		counter.Dec()

		Expect(counter.Max()).To(Equal(2))
	})

	It("deals with concurrent increments correctly", func() {
		// buckle up
		defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU()))

		totalIncs := 30
		wg := new(sync.WaitGroup)
		wg.Add(totalIncs)

		for i := 0; i < totalIncs; i++ {
			go func() {
				counter.Inc()
				wg.Done()
			}()
		}

		wg.Wait()

		Expect(counter.Max()).To(Equal(totalIncs))
	})

	It("resets the max to the current value when observed", func() {
		counter.Inc()
		counter.Inc()
		counter.Dec()

		Expect(counter.Max()).To(Equal(2))

		Expect(counter.Max()).To(Equal(1))
	})
})

{'fraction_non_alphanumeric': 0.18069916297390448, 'fraction_numerical': 0.009847365829640572, 'mean_word_length': 3.6498855835240276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5179780', 'n_tokens_mistral': 867, 'n_tokens_neox': 754, 'n_words': 146}