Codebase list golang-github-go-kit-kit / d2f2902b-79c4-43cd-8c09-341e33fc6017/v0.1.0 log / concurrency_test.go
d2f2902b-79c4-43cd-8c09-341e33fc6017/v0.1.0

Tree @d2f2902b-79c4-43cd-8c09-341e33fc6017/v0.1.0 (Download .tar.gz)

concurrency_test.go @d2f2902b-79c4-43cd-8c09-341e33fc6017/v0.1.0raw · history · blame

package log_test

import (
	"strconv"
	"sync"
	"testing"

	"github.com/go-kit/kit/log"
)

// These test are designed to be run with the race detector.

func testConcurrency(t *testing.T, logger log.Logger) {
	for _, n := range []int{10, 100, 500} {
		wg := sync.WaitGroup{}
		wg.Add(n)
		for i := 0; i < n; i++ {
			go func() { spam(logger); wg.Done() }()
		}
		wg.Wait()
	}
}

func spam(logger log.Logger) {
	for i := 0; i < 100; i++ {
		logger.Log("key", strconv.FormatInt(int64(i), 10))
	}
}