github.com/noriah/catnip@v1.8.5/processor/processor_test.go (about) 1 package processor 2 3 import ( 4 "sync" 5 "testing" 6 7 "github.com/noriah/catnip/input" 8 ) 9 10 const ( 11 BinSize = 1024 12 ChCount = 2 13 ) 14 15 type testOutput struct{} 16 17 func (tO *testOutput) Bins(int) int { 18 return BinSize 19 } 20 21 func (tO *testOutput) Write([][]float64, int) error { 22 return nil 23 } 24 25 type testAnalyzer struct{} 26 27 func (tA *testAnalyzer) BinCount() int { 28 return BinSize 29 } 30 31 func (tA *testAnalyzer) ProcessBin(int, []complex128) float64 { 32 return 0.0 33 } 34 35 func (ta *testAnalyzer) Recalculate(int) int { 36 return BinSize 37 } 38 39 type Analyzer interface { 40 BinCount() int 41 ProcessBin(int, []complex128) float64 42 Recalculate(int) int 43 } 44 45 func BenchmarkSlices(b *testing.B) { 46 47 inputBuffers := input.MakeBuffers(ChCount, BinSize) 48 49 cfg := Config{ 50 SampleRate: 122880.0, 51 SampleSize: BinSize, 52 ChannelCount: ChCount, 53 Buffers: inputBuffers, 54 Output: &testOutput{}, 55 Analyzer: &testAnalyzer{}, 56 } 57 58 proc := New(cfg) 59 proc.mu = &sync.Mutex{} 60 61 b.ResetTimer() 62 63 for i := 0; i < b.N; i++ { 64 proc.Process() 65 } 66 }