feat: Add benchmark tests

This commit is contained in:
rjianu
2023-07-12 15:32:29 +03:00
parent b1f95ed90c
commit 9fec648bc8
4 changed files with 25 additions and 2 deletions

View File

@@ -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)
}
}
}