bson.M{"$in": teamNames}} var teams []Team conn, err := db.Conn() if err != nil { log.Errorf("Failed to connect to the database: %s", err) return false } defer conn.Close() conn.Teams().Find(q).All(&teams) var wg sync.WaitGroup found := make(chan bool, len(teams)+1) for _, team := range teams { wg.Add(1) go func(t Team) { if t.ContainsUser(u) { found <- true } wg.Done() }(team) } go func() { wg.Wait() found <- false }() return <-found } https://github.com/tsuru/tsuru/blob/c54c2c073aa9bf1db888a0bed45ffafbf62cbf18/auth/team.go
team := range teams { wg.Add(1) go func(t Team) { if t.ContainsUser(u) { found <- true } wg.Done() }(team) } go func() { wg.Wait() found <- false }() return <-found
bson.M{"$in": teamNames}} var teams []Team conn, err := db.Conn() if err != nil { log.Errorf("Failed to connect to the database: %s", err) return false } defer conn.Close() conn.Teams().Find(q).All(&teams) for _, team := range teams { if team.ContainsUser(u) { return true } } return false } https://github.com/tsuru/tsuru/blob/fafa683c5cc1e736df03116b11fc5868c54e30d5/auth/team.go#L138
Performance Tools • Julia Evans’ blog: tcpdump, tcpdump 2 • Unix/Linux Handbook • Diving into the Wreck: a postmortem look at real-works performance • Ragel • Profiling Go program • perf • FlameGraph • CPU Flame Graph Referências