From eb2d1a782c0bd66413fc45e66848baf774511c83 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 3 Apr 2017 19:13:12 +0000 Subject: benchcomp: Add a mode for analyzing file sizes. llvm-svn: 299376 --- llgo/utils/benchcomp/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'llgo') diff --git a/llgo/utils/benchcomp/main.go b/llgo/utils/benchcomp/main.go index a050f7bdd5f..69eb6d1a914 100644 --- a/llgo/utils/benchcomp/main.go +++ b/llgo/utils/benchcomp/main.go @@ -6,6 +6,7 @@ import ( "debug/macho" "fmt" "os" + "path/filepath" "sort" "strconv" "strings" @@ -138,6 +139,22 @@ func ninja_logs(path string) map[string]float64 { return m } +func filesizes(root string) map[string]float64 { + m := make(map[string]float64) + + err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if info.Mode().IsRegular() { + m[path[len(root):]] = float64(info.Size()) + } + return nil + }) + if err != nil { + panic(err.Error()) + } + + return m +} + func main() { var cmp func(string) map[string]float64 switch os.Args[1] { @@ -159,6 +176,9 @@ func main() { case "ninja_logs": cmp = ninja_logs + + case "filesizes": + cmp = filesizes } syms1 := cmp(os.Args[2]) -- cgit v1.2.3