diff options
author | jan <jan@ruken.pw> | 2016-03-27 17:46:17 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-03-27 17:46:17 (UTC) |
commit | c7f28c0032163075bd21f899c37ae992e3eece80 (patch) | |
tree | 18c580c2f260e93ac97ddb4b4ec42bcae7e58254 /dashboard.go | |
parent | 876530b3da8377e7072824bca5b3844c682eb37a (diff) |
temporaer laufzeiten der module (dashboard data) loggen, views angepasst, dashboard in goroutines aufgeteilt, weniger daten fuers listendashboard holen (reduktion von 6s -> 300ms insgesamt)
Diffstat (limited to 'dashboard.go')
-rw-r--r-- | dashboard.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/dashboard.go b/dashboard.go index 0ca38ef..ad3c565 100644 --- a/dashboard.go +++ b/dashboard.go | |||
@@ -3,7 +3,10 @@ package main | |||
3 | import ( | 3 | import ( |
4 | "fagott.pw/grilist/grilist" | 4 | "fagott.pw/grilist/grilist" |
5 | "github.com/julienschmidt/httprouter" | 5 | "github.com/julienschmidt/httprouter" |
6 | "log" | ||
6 | "net/http" | 7 | "net/http" |
8 | "sync" | ||
9 | "time" | ||
7 | ) | 10 | ) |
8 | 11 | ||
9 | func viewDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | 12 | func viewDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { |
@@ -11,13 +14,24 @@ func viewDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params) | |||
11 | 14 | ||
12 | var categories []grilist.DashboardCategory | 15 | var categories []grilist.DashboardCategory |
13 | 16 | ||
17 | t1 := time.Now() | ||
18 | var wg sync.WaitGroup | ||
14 | for _, module := range app.Modules { | 19 | for _, module := range app.Modules { |
15 | for _, category := range module.ProvideDashboardData(user) { | 20 | wg.Add(1) |
16 | if len(category.Cards) > 0 { | 21 | go func(module grilist.Module) { |
17 | categories = append(categories, category) | 22 | t2 := time.Now() |
23 | for _, category := range module.ProvideDashboardData(user) { | ||
24 | if len(category.Cards) > 0 { | ||
25 | categories = append(categories, category) | ||
26 | } | ||
18 | } | 27 | } |
19 | } | 28 | log.Printf("%s dashboard_data: %dms", module.Name(), time.Since(t2).Nanoseconds()/1000000) |
29 | wg.Done() | ||
30 | }(module) | ||
20 | } | 31 | } |
32 | wg.Wait() | ||
33 | |||
34 | log.Printf("dashboard_data: %dms", time.Since(t1).Nanoseconds()/1000000) | ||
21 | 35 | ||
22 | data := make(map[string]interface{}) | 36 | data := make(map[string]interface{}) |
23 | data["categories"] = categories | 37 | data["categories"] = categories |