feat: Add benchmark tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -0,0 +1 @@
|
||||
benchmark
|
||||
6
benchresults.txt
Normal file
6
benchresults.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/Serares/coolStats
|
||||
BenchmarkRun-16 10 326633135 ns/op
|
||||
PASS
|
||||
ok github.com/Serares/coolStats 3.594s
|
||||
@@ -45,8 +45,8 @@ func TestCSV2Float(t *testing.T) {
|
||||
192.168.0.88,899,220
|
||||
192.168.0.199,3054,226
|
||||
192.168.0.100,4133,218
|
||||
192.168.0.199,950,238
|
||||
`
|
||||
192.168.0.199,950,238`
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
col int
|
||||
|
||||
16
main_test.go
16
main_test.go
@@ -3,7 +3,9 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -65,3 +67,17 @@ func TestRun(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRun(b *testing.B) {
|
||||
filenames, err := filepath.Glob("./testdata/benchmark/*.csv")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
// reset the time before running the benchmark loop
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err := run(filenames, "avg", 2, io.Discard); err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user