fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Print statistics on number of bytes loaded.

+23 -1
+20
api.go
··· 15 15 package zoekt 16 16 17 17 import ( 18 + "fmt" 18 19 "time" 19 20 ) 20 21 ··· 55 56 NgramMatches int 56 57 FilesConsidered int 57 58 FilesLoaded int 59 + BytesLoaded int64 58 60 FileCount int 59 61 MatchCount int 60 62 Duration time.Duration 61 63 } 62 64 65 + func (s Stats) HumanBytesLoaded() string { 66 + suffix := "" 67 + b := s.BytesLoaded 68 + if s.BytesLoaded > (1 << 30) { 69 + suffix = "G" 70 + b = s.BytesLoaded / (1 << 30) 71 + } else if s.BytesLoaded > (1 << 20) { 72 + suffix = "M" 73 + b = s.BytesLoaded / (1 << 20) 74 + } else if s.BytesLoaded > (1 << 10) { 75 + suffix = "K" 76 + b = s.BytesLoaded / (1 << 10) 77 + } 78 + 79 + return fmt.Sprintf("%d%s", b, suffix) 80 + } 81 + 63 82 func (s *Stats) Add(o Stats) { 64 83 s.NgramMatches += o.NgramMatches 65 84 s.FilesLoaded += o.FilesLoaded 66 85 s.MatchCount += o.MatchCount 67 86 s.FileCount += o.FileCount 68 87 s.FilesConsidered += o.FilesConsidered 88 + s.BytesLoaded += o.BytesLoaded 69 89 } 70 90 71 91 // SearchResult contains search matches and extra data
+1 -1
cmd/server/main.go
··· 138 138 <body>` + searchBox + 139 139 ` <hr> 140 140 Found {{.Stats.MatchCount}} results in {{.Stats.FileCount}} files ({{.Stats.NgramMatches}} ngram matches, 141 - {{.Stats.FilesConsidered}} docs considered, {{.Stats.FilesLoaded}} docs loaded): for 141 + {{.Stats.FilesConsidered}} docs considered, {{.Stats.FilesLoaded}} docs loaded, {{.Stats.HumanBytesLoaded}}B): for 142 142 <pre style="background: #ffc;">{{.Query}}</pre> 143 143 in {{.Stats.Duration}} 144 144 <p>
+1
index_test.go
··· 296 296 297 297 wantStats := Stats{ 298 298 FilesLoaded: 1, 299 + BytesLoaded: 22, 299 300 NgramMatches: 4, 300 301 MatchCount: 2, 301 302 FileCount: 1,
+1
search.go
··· 47 47 if p._data == nil { 48 48 p._data = p.reader.readContents(p.id, p.idx) 49 49 p.stats.FilesLoaded++ 50 + p.stats.BytesLoaded += int64(len(p._data)) 50 51 } 51 52 return p._data 52 53 }