diff --git a/filter/filter_test.go b/filter/filter_test.go index d741069c..47800d52 100644 --- a/filter/filter_test.go +++ b/filter/filter_test.go @@ -25,18 +25,9 @@ LICENSE package filter import ( - "io" - "os" "testing" ) -const ( - outBasic = "testout/test_outBasic.mjpeg" - outDiff = "testout/test_outDiff.mjpeg" - outKNN = "testout/test_outKNN.mjpeg" - outMOG = "testout/test_outMOG.mjpeg" -) - const ( debug = false motionDownscaling = 1 @@ -57,9 +48,15 @@ const ( MOGHistory = 500 ) +type d struct { +} + +func (d *d) Write(p []byte) (int, error) { return len(p), nil } +func (d *d) Close() error { return nil } + func BenchmarkBasic(b *testing.B) { - file, _ := os.Create(outBasic) - f := NewBasic(io.WriteCloser(file), debug, BasicThreshold, BasicPixels) + buffer := &d{} + f := NewBasic(buffer, debug, BasicThreshold, BasicPixels) b.Log("Frames: ", len(testPackets)) for n := 0; n < b.N; n++ { for _, x := range testPackets { @@ -72,8 +69,8 @@ func BenchmarkBasic(b *testing.B) { } func BenchmarkDifference(b *testing.B) { - file, _ := os.Create(outDiff) - f := NewDifference(io.WriteCloser(file), debug, DiffThreshold) + buffer := &d{} + f := NewDifference(buffer, debug, DiffThreshold) b.Log("Frames: ", len(testPackets)) for n := 0; n < b.N; n++ { for _, x := range testPackets { @@ -86,8 +83,8 @@ func BenchmarkDifference(b *testing.B) { } func BenchmarkKNN(b *testing.B) { - file, _ := os.Create(outKNN) - f := NewKNN(io.WriteCloser(file), KNNMinArea, KNNThreshold, KNNHistory, KNNKernel, debug, motionInterval, motionDownscaling) + buffer := &d{} + f := NewKNN(buffer, KNNMinArea, KNNThreshold, KNNHistory, KNNKernel, debug, motionInterval, motionDownscaling) b.Log("Frames: ", len(testPackets)) for n := 0; n < b.N; n++ { for _, x := range testPackets { @@ -100,8 +97,8 @@ func BenchmarkKNN(b *testing.B) { } func BenchmarkMOG(b *testing.B) { - file, _ := os.Create(outMOG) - f := NewMOG(io.WriteCloser(file), MOGMinArea, MOGThreshold, MOGHistory, debug, motionInterval, motionDownscaling) + buffer := &d{} + f := NewMOG(buffer, MOGMinArea, MOGThreshold, MOGHistory, debug, motionInterval, motionDownscaling) b.Log("Frames: ", len(testPackets)) for n := 0; n < b.N; n++ { for _, x := range testPackets {