mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 03:46:45 +00:00
add a benchmark for report unmarshalling
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user