Skip to content

Commit 2e6956c

Browse files
Adding in cache testing
1 parent 9c7fbd0 commit 2e6956c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

build/cache/cache.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ func ClearStats() {
101101
FilePaths = map[string]*FilePathStats{}
102102
}
103103

104+
func statsPath(path string) string {
105+
if strings.HasPrefix(path, cacheRoot) {
106+
path = `..` + path[len(cacheRoot):]
107+
}
108+
if len(path) > 20 {
109+
path = path[:20]
110+
}
111+
return path
112+
}
113+
104114
func StatsString() string {
105115
buf := &strings.Builder{}
106116

@@ -138,13 +148,13 @@ func StatsString() string {
138148
fmt.Fprintf(buf, "{%s: ", im)
139149
fp := FilePaths[im]
140150
if fp.StoreCount > 0 {
141-
fmt.Fprintf(buf, "%s (%d)", fp.StorePath, fp.StoreCount)
151+
fmt.Fprintf(buf, "%s (%d)", statsPath(fp.StorePath), fp.StoreCount)
142152
}
143153
if fp.LoadCount > 0 {
144154
if fp.StorePath == fp.LoadPath {
145-
fmt.Fprintf(buf, " - \" (%d)", fp.LoadCount)
155+
fmt.Fprintf(buf, "-(%d)", fp.LoadCount)
146156
} else {
147-
fmt.Fprintf(buf, " - %s (%d)", fp.LoadPath, fp.LoadCount)
157+
fmt.Fprintf(buf, "- %s (%d)", statsPath(fp.LoadPath), fp.LoadCount)
148158
}
149159
}
150160
fmt.Fprintf(buf, "}")

0 commit comments

Comments
 (0)