Skip to content

Commit

Permalink
add a benchmark for report unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
rade committed Nov 29, 2017
1 parent d5eab89 commit ecf3ae9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions report/benchmark_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package report

import (
"flag"
"os"
"path/filepath"
"testing"
)

var (
benchReportPath = flag.String("bench-report-path", "", "report file, or dir with files, to use for benchmarking (relative to this package)")
)

func BenchmarkReportUnmarshal(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
b.StartTimer()
if err := readReportFiles(*benchReportPath); err != nil {
b.Fatal(err)
}
}
}

func readReportFiles(path string) error {
return filepath.Walk(path,
func(p string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if _, err := MakeFromFile(p); err != nil {
return err
}
return nil
})
}

0 comments on commit ecf3ae9

Please sign in to comment.