<commit_before>package internal_test

import (
	"testing"
	"time"

	"github.com/instana/go-sensor/autoprofile/internal"
	"github.com/stretchr/testify/assert"
)

func TestTimer_Restart(t *testing.T) {
	var fired int
	timer := internal.NewTimer(0, 10*time.Millisecond, func() {
		fired++
	})

	time.Sleep(15 * time.Millisecond)
	timer.Stop()

	assert.Equal(t, 1, fired)

	time.Sleep(30 * time.Millisecond)
	assert.Equal(t, 1, fired)
}

func TestTimer_Sleep(t *testing.T) {
	var fired int
	timer := internal.NewTimer(10*time.Millisecond, 0, func() {
		fired++
	})

	time.Sleep(15 * time.Millisecond)
	timer.Stop()

	assert.Equal(t, 1, fired)
}

func TestTimer_Sleep_Stopped(t *testing.T) {
	var fired int
	timer := internal.NewTimer(10*time.Millisecond, 0, func() {
		fired++
	})

	timer.Stop()
	time.Sleep(15 * time.Millisecond)

	assert.Equal(t, 0, fired)
}<commit_msg>Increase the time between the timer ticks to make calls to Stop() in-between more reliable<commit_after>package internal_test

import (
	"testing"
	"time"

	"github.com/instana/go-sensor/autoprofile/internal"
	"github.com/stretchr/testify/assert"
)

func TestTimer_Restart(t *testing.T) {
	var fired int
	timer := internal.NewTimer(0, 20*time.Millisecond, func() {
		fired++
	})

	time.Sleep(30 * time.Millisecond)
	timer.Stop()

	assert.Equal(t, 1, fired)

	time.Sleep(50 * time.Millisecond)
	assert.Equal(t, 1, fired)
}

func TestTimer_Sleep(t *testing.T) {
	var fired int
	timer := internal.NewTimer(20*time.Millisecond, 0, func() {
		fired++
	})

	time.Sleep(30 * time.Millisecond)
	timer.Stop()

	assert.Equal(t, 1, fired)
}

func TestTimer_Sleep_Stopped(t *testing.T) {
	var fired int
	timer := internal.NewTimer(20*time.Millisecond, 0, func() {
		fired++
	})

	timer.Stop()
	time.Sleep(30 * time.Millisecond)

	assert.Equal(t, 0, fired)
}
{'fraction_non_alphanumeric': 0.15057915057915058, 'fraction_numerical': 0.023166023166023165, 'mean_word_length': 4.431137724550898, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7038898', 'n_tokens_mistral': 761, 'n_tokens_neox': 689, 'n_words': 140}