<commit_before>package kafka

import (
	"sync"
	"testing"
	"time"

	"github.com/funkygao/gafka/ctx"
	"github.com/funkygao/golib/pool"
	log "github.com/funkygao/log4go"
)

func init() {
	ctx.LoadConfig("/etc/kateway.cf")
	log.AddFilter("stdout", log.INFO, log.NewConsoleLogWriter())
}

func BenchmarkPubPool(b *testing.B) {
	s := NewPubStore(nil, false)
	p := newPubPool(s, []string{"localhost:9092"}, 100)
	for i := 0; i < b.N; i++ {
		c, err := p.GetSyncProducer()
		if err != nil {
			b.Fatal(err)
		}

		c.Recycle()
	}
	s.Stop()
}

type TestResource struct {
	num    int64
	closed bool
}

func (tr *TestResource) Close() {
}

func (this *TestResource) Id() uint64 {
	return 1
}

func PoolFactory() (pool.Resource, error) {
	return &TestResource{1, false}, nil
}<commit_msg>fix benchmark test compile err<commit_after>package kafka

import (
	"sync"
	"testing"
	"time"

	"github.com/funkygao/gafka/ctx"
	"github.com/funkygao/golib/pool"
	log "github.com/funkygao/log4go"
)

func init() {
	ctx.LoadConfig("/etc/kateway.cf")
	log.AddFilter("stdout", log.INFO, log.NewConsoleLogWriter())
}

func BenchmarkPubPool(b *testing.B) {
	s := NewPubStore(100, 5, 0, nil, false, true)
	p := newPubPool(s, []string{"localhost:9092"}, 100)
	for i := 0; i < b.N; i++ {
		c, err := p.GetSyncProducer()
		if err != nil {
			b.Fatal(err)
		}

		c.Recycle()
	}
	s.Stop()
}

type TestResource struct {
	num    int64
	closed bool
}

func (tr *TestResource) Close() {
}

func (this *TestResource) Id() uint64 {
	return 1
}

func PoolFactory() (pool.Resource, error) {
	return &TestResource{1, false}, nil
}
{'fraction_non_alphanumeric': 0.17023959646910466, 'fraction_numerical': 0.022068095838587643, 'mean_word_length': 3.9749216300940438, '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': '3088857', 'n_tokens_mistral': 696, 'n_tokens_neox': 649, 'n_words': 142}