Skip to content

Commit

Permalink
Adding in cache testing
Browse files Browse the repository at this point in the history
  • Loading branch information
grantnelson-wf committed Dec 12, 2024
1 parent 9c7fbd0 commit 2e6956c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions build/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ func ClearStats() {
FilePaths = map[string]*FilePathStats{}
}

func statsPath(path string) string {
if strings.HasPrefix(path, cacheRoot) {
path = `..` + path[len(cacheRoot):]
}
if len(path) > 20 {
path = path[:20]
}
return path
}

func StatsString() string {
buf := &strings.Builder{}

Expand Down Expand Up @@ -138,13 +148,13 @@ func StatsString() string {
fmt.Fprintf(buf, "{%s: ", im)
fp := FilePaths[im]
if fp.StoreCount > 0 {
fmt.Fprintf(buf, "%s (%d)", fp.StorePath, fp.StoreCount)
fmt.Fprintf(buf, "%s (%d)", statsPath(fp.StorePath), fp.StoreCount)
}
if fp.LoadCount > 0 {
if fp.StorePath == fp.LoadPath {
fmt.Fprintf(buf, " - \" (%d)", fp.LoadCount)
fmt.Fprintf(buf, "-(%d)", fp.LoadCount)
} else {
fmt.Fprintf(buf, " - %s (%d)", fp.LoadPath, fp.LoadCount)
fmt.Fprintf(buf, "- %s (%d)", statsPath(fp.LoadPath), fp.LoadCount)
}
}
fmt.Fprintf(buf, "}")
Expand Down

0 comments on commit 2e6956c

Please sign in to comment.