feat: Add benchmark tests
This commit is contained in:
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