stats for rill
This commit is contained in:
parent
46c11e7d33
commit
5147aa73de
48
rill.go
48
rill.go
|
@ -154,11 +154,10 @@ func (f *Forge) RillFuncError(rillf func(*gitpb.Repo) error) int {
|
||||||
func (f *Forge) ConfigRill(rillX int, rillY int) {
|
func (f *Forge) ConfigRill(rillX int, rillY int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type rillStats struct {
|
type RillStats struct {
|
||||||
fullpath string
|
Err error
|
||||||
err error
|
Start time.Time
|
||||||
start time.Time
|
End time.Time
|
||||||
end time.Time
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var rillMu sync.Mutex
|
var rillMu sync.Mutex
|
||||||
|
@ -167,14 +166,14 @@ var rillMu sync.Mutex
|
||||||
// y is how many simultanous functions will run
|
// y is how many simultanous functions will run
|
||||||
// todo: tune and compute x,y by # of CPUs and disk io
|
// todo: tune and compute x,y by # of CPUs and disk io
|
||||||
// todo: store x,y in forge config ? (or compute them. notsure)
|
// todo: store x,y in forge config ? (or compute them. notsure)
|
||||||
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[string]*RillStats {
|
||||||
var all []*gitpb.Repo
|
var all []*gitpb.Repo
|
||||||
|
|
||||||
var allerr map[*gitpb.Repo]error
|
var allerr map[*gitpb.Repo]error
|
||||||
allerr = make(map[*gitpb.Repo]error)
|
allerr = make(map[*gitpb.Repo]error)
|
||||||
|
|
||||||
var stats map[string]rillStats
|
var stats map[string]*RillStats
|
||||||
stats = make(map[string]rillStats)
|
stats = make(map[string]*RillStats)
|
||||||
|
|
||||||
for repo := range f.Repos.IterAll() {
|
for repo := range f.Repos.IterAll() {
|
||||||
if !repo.IsValidDir() {
|
if !repo.IsValidDir() {
|
||||||
|
@ -203,26 +202,49 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
||||||
watch += 50
|
watch += 50
|
||||||
}
|
}
|
||||||
rillMu.Unlock()
|
rillMu.Unlock()
|
||||||
|
rillSetStartTime(stats, repo.GetFullPath())
|
||||||
if err := rillf(repo); err != nil {
|
if err := rillf(repo); err != nil {
|
||||||
rillMu.Lock()
|
rillMu.Lock()
|
||||||
allerr[repo] = err
|
allerr[repo] = err
|
||||||
rillMu.Unlock()
|
rillMu.Unlock()
|
||||||
rillSetError(stats, repo.GetFullPath(), err)
|
rillSetError(stats, repo.GetFullPath(), err)
|
||||||
}
|
}
|
||||||
|
rillSetEndTime(stats, repo.GetFullPath())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return allerr
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
func rillSetError(stats map[string]rillStats, fullpath string, err error) {
|
func rillSetError(stats map[string]*RillStats, fullpath string, err error) {
|
||||||
rillMu.Lock()
|
rillMu.Lock()
|
||||||
defer rillMu.Unlock()
|
defer rillMu.Unlock()
|
||||||
if s, ok := stats[fullpath]; ok {
|
if s, ok := stats[fullpath]; ok {
|
||||||
s.err = err
|
s.Err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var s rillStats
|
log.Info("WHAT THE FUCK STATS ERROR", fullpath)
|
||||||
s.err = err
|
}
|
||||||
|
|
||||||
|
func rillSetStartTime(stats map[string]*RillStats, fullpath string) {
|
||||||
|
rillMu.Lock()
|
||||||
|
defer rillMu.Unlock()
|
||||||
|
if s, ok := stats[fullpath]; ok {
|
||||||
|
s.Start = time.Now()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var s *RillStats
|
||||||
|
s = new(RillStats)
|
||||||
|
s.Start = time.Now()
|
||||||
stats[fullpath] = s
|
stats[fullpath] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rillSetEndTime(stats map[string]*RillStats, fullpath string) {
|
||||||
|
rillMu.Lock()
|
||||||
|
defer rillMu.Unlock()
|
||||||
|
if s, ok := stats[fullpath]; ok {
|
||||||
|
s.End = time.Now()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info("WHAT THE FUCK STATS END TIME", fullpath)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue