mirror of https://bitbucket.org/ausocean/av.git
filter: benchmark: tidying code
This commit is contained in:
parent
e73be1e30a
commit
8dfddfbc1e
|
@ -32,20 +32,21 @@ import (
|
||||||
"bitbucket.org/ausocean/utils/logger"
|
"bitbucket.org/ausocean/utils/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type d struct {
|
const downscale = 1
|
||||||
}
|
|
||||||
|
|
||||||
func (d *d) Write(p []byte) (int, error) { return len(p), nil }
|
type dumbWriteCloser struct{}
|
||||||
func (d *d) Close() error { return nil }
|
|
||||||
|
func (d *dumbWriteCloser) Write(p []byte) (int, error) { return len(p), nil }
|
||||||
|
func (d *dumbWriteCloser) Close() error { return nil }
|
||||||
|
|
||||||
func BenchmarkBasic(b *testing.B) {
|
func BenchmarkBasic(b *testing.B) {
|
||||||
log := logger.New(logger.Debug, &bytes.Buffer{}, true)
|
cfg := config.Config{Logger: logger.New(logger.Debug, &bytes.Buffer{}, true)}
|
||||||
cfg := config.Config{Logger: log}
|
|
||||||
err := cfg.Validate()
|
err := cfg.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Config struct is bad: %v#", err)
|
b.Fatalf("Config struct is bad: %v#", err)
|
||||||
}
|
}
|
||||||
buffer := &d{}
|
|
||||||
|
buffer := &dumbWriteCloser{}
|
||||||
f := NewBasic(buffer, cfg)
|
f := NewBasic(buffer, cfg)
|
||||||
b.Log("Frames: ", len(testPackets))
|
b.Log("Frames: ", len(testPackets))
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
@ -59,13 +60,13 @@ func BenchmarkBasic(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkDifference(b *testing.B) {
|
func BenchmarkDifference(b *testing.B) {
|
||||||
log := logger.New(logger.Debug, &bytes.Buffer{}, true)
|
cfg := config.Config{Logger: logger.New(logger.Debug, &bytes.Buffer{}, true)}
|
||||||
cfg := config.Config{Logger: log}
|
|
||||||
err := cfg.Validate()
|
err := cfg.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Config struct is bad: %v#", err)
|
b.Fatalf("Config struct is bad: %v#", err)
|
||||||
}
|
}
|
||||||
buffer := &d{}
|
|
||||||
|
buffer := &dumbWriteCloser{}
|
||||||
f := NewDiff(buffer, cfg)
|
f := NewDiff(buffer, cfg)
|
||||||
b.Log("Frames: ", len(testPackets))
|
b.Log("Frames: ", len(testPackets))
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
@ -79,14 +80,13 @@ func BenchmarkDifference(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkKNN(b *testing.B) {
|
func BenchmarkKNN(b *testing.B) {
|
||||||
log := logger.New(logger.Debug, &bytes.Buffer{}, true)
|
cfg := config.Config{Logger: logger.New(logger.Debug, &bytes.Buffer{}, true), MotionDownscaling: downscale}
|
||||||
cfg := config.Config{Logger: log}
|
|
||||||
err := cfg.Validate()
|
err := cfg.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Config struct is bad: %v#", err)
|
b.Fatalf("Config struct is bad: %v#", err)
|
||||||
}
|
}
|
||||||
cfg.MotionDownscaling = 1
|
|
||||||
buffer := &d{}
|
buffer := &dumbWriteCloser{}
|
||||||
f := NewKNN(buffer, cfg)
|
f := NewKNN(buffer, cfg)
|
||||||
b.Log("Frames: ", len(testPackets))
|
b.Log("Frames: ", len(testPackets))
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
@ -100,14 +100,13 @@ func BenchmarkKNN(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMOG(b *testing.B) {
|
func BenchmarkMOG(b *testing.B) {
|
||||||
log := logger.New(logger.Debug, &bytes.Buffer{}, true)
|
cfg := config.Config{Logger: logger.New(logger.Debug, &bytes.Buffer{}, true), MotionDownscaling: downscale}
|
||||||
cfg := config.Config{Logger: log}
|
|
||||||
err := cfg.Validate()
|
err := cfg.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Config struct is bad: %v#", err)
|
b.Fatalf("Config struct is bad: %v#", err)
|
||||||
}
|
}
|
||||||
cfg.MotionDownscaling = 1
|
|
||||||
buffer := &d{}
|
buffer := &dumbWriteCloser{}
|
||||||
f := NewMOG(buffer, cfg)
|
f := NewMOG(buffer, cfg)
|
||||||
b.Log("Frames: ", len(testPackets))
|
b.Log("Frames: ", len(testPackets))
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
|
|
Loading…
Reference in New Issue