mirror of https://bitbucket.org/ausocean/av.git
filter: benchmark: upadte headers, add consts, print to log
This commit is contained in:
parent
ab30dff020
commit
42fe6e05ac
|
@ -1,15 +1,12 @@
|
|||
/*
|
||||
NAME
|
||||
filter_test.go
|
||||
|
||||
DESCRIPTION
|
||||
See Readme.md
|
||||
filter_test.go contains benchmarking tests for each filter implementation.
|
||||
|
||||
AUTHORS
|
||||
Ella Pietraroia <ella@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
This is Copyright (C) 2019 the Australian Ocean Lab (AusOcean).
|
||||
This is Copyright (C) 2020 the Australian Ocean Lab (AusOcean).
|
||||
|
||||
It is free software: you can redistribute it and/or modify them
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
@ -28,17 +25,41 @@ LICENSE
|
|||
package filter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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
|
||||
motionInterval = 1
|
||||
|
||||
BasicThreshold = 45000
|
||||
BasicPixels = 1000
|
||||
|
||||
DiffThreshold = 3
|
||||
|
||||
KNNMinArea = 25.0
|
||||
KNNThreshold = 300
|
||||
KNNHistory = 300
|
||||
KNNKernel = 9
|
||||
|
||||
MOGMinArea = 25.0
|
||||
MOGThreshold = 20.0
|
||||
MOGHistory = 500
|
||||
)
|
||||
|
||||
func BenchmarkBasic(b *testing.B) {
|
||||
file, _ := os.Create("testout/test_outBasic.mjpeg")
|
||||
w := io.WriteCloser(file)
|
||||
f := NewBasic(w, false, 45000, 1000)
|
||||
fmt.Print("\nFrames: ", len(testPackets), "\t")
|
||||
file, _ := os.Create(outBasic)
|
||||
f := NewBasic(io.WriteCloser(file), debug, BasicThreshold, BasicPixels)
|
||||
b.Log("\nFrames: ", len(testPackets))
|
||||
for n := 0; n < b.N; n++ {
|
||||
for _, x := range testPackets {
|
||||
f.Write(x)
|
||||
|
@ -47,10 +68,9 @@ func BenchmarkBasic(b *testing.B) {
|
|||
}
|
||||
|
||||
func BenchmarkDifference(b *testing.B) {
|
||||
file, _ := os.Create("testout/test_outDiff.mjpeg")
|
||||
w := io.WriteCloser(file)
|
||||
f := NewDifference(w, false, 3)
|
||||
fmt.Print("\nFrames: ", len(testPackets), "\t")
|
||||
file, _ := os.Create(outDiff)
|
||||
f := NewDifference(io.WriteCloser(file), debug, DiffThreshold)
|
||||
b.Log("\nFrames: ", len(testPackets))
|
||||
for n := 0; n < b.N; n++ {
|
||||
for _, x := range testPackets {
|
||||
f.Write(x)
|
||||
|
@ -59,10 +79,9 @@ func BenchmarkDifference(b *testing.B) {
|
|||
}
|
||||
|
||||
func BenchmarkKNN(b *testing.B) {
|
||||
file, _ := os.Create("testout/test_outKNN.mjpeg")
|
||||
w := io.WriteCloser(file)
|
||||
f := NewKNN(w, 25, 20, 300, 9, false, 1, 1)
|
||||
fmt.Print("\nFrames: ", len(testPackets), "\t")
|
||||
file, _ := os.Create(outKNN)
|
||||
f := NewKNN(io.WriteCloser(file), KNNMinArea, KNNThreshold, KNNHistory, KNNKernel, debug, motionInterval, motionDownscaling)
|
||||
b.Log("\nFrames: ", len(testPackets))
|
||||
for n := 0; n < b.N; n++ {
|
||||
for _, x := range testPackets {
|
||||
f.Write(x)
|
||||
|
@ -71,10 +90,9 @@ func BenchmarkKNN(b *testing.B) {
|
|||
}
|
||||
|
||||
func BenchmarkMOG(b *testing.B) {
|
||||
file, _ := os.Create("testout/test_outMOG.mjpeg")
|
||||
w := io.WriteCloser(file)
|
||||
f := NewMOG(w, 25, 20, 500, false, 1, 1)
|
||||
fmt.Print("\nFrames: ", len(testPackets), "\t")
|
||||
file, _ := os.Create(outMOG)
|
||||
f := NewMOG(io.WriteCloser(file), MOGMinArea, MOGThreshold, MOGHistory, debug, motionInterval, motionDownscaling)
|
||||
b.Log("\nFrames: ", len(testPackets))
|
||||
for n := 0; n < b.N; n++ {
|
||||
for _, x := range testPackets {
|
||||
f.Write(x)
|
||||
|
|
|
@ -8,7 +8,7 @@ AUTHOR
|
|||
Ella Pietraroia <ella@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||
Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
|
||||
|
||||
It is free software: you can redistribute it and/or modify them
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
|
Loading…
Reference in New Issue