-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2386 from weaveworks/decode-bytes
Decode reports from a byte buffer
- Loading branch information
Showing
2 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters