From 6cc677761df3efa27a1c22162f6bc70ee1b592e5 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 10 Jun 2022 16:13:13 +0000 Subject: [PATCH] Report test-based aggregation of CTS times Adds an "-aggregate" flags to ./tools/run/cts time to report results aggregated by test Change-Id: Id8d15188846b3bff79ac4c65a09e5d6740acde73 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93300 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Austin Eng --- tools/src/cmd/cts/time/time.go | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/src/cmd/cts/time/time.go b/tools/src/cmd/cts/time/time.go index 7bcb682a06..302071fea8 100644 --- a/tools/src/cmd/cts/time/time.go +++ b/tools/src/cmd/cts/time/time.go @@ -23,6 +23,7 @@ import ( "time" "dawn.googlesource.com/dawn/tools/src/cmd/cts/common" + "dawn.googlesource.com/dawn/tools/src/cts/query" "dawn.googlesource.com/dawn/tools/src/cts/result" "dawn.googlesource.com/dawn/tools/src/subcmd" "go.chromium.org/luci/auth/client/authcli" @@ -37,6 +38,7 @@ type cmd struct { source common.ResultSource auth authcli.Flags tags string + aggregate bool topN int histogram bool } @@ -56,6 +58,7 @@ func (c *cmd) RegisterFlags(ctx context.Context, cfg common.Config) ([]string, e flag.IntVar(&c.flags.topN, "top", 0, "print the top N slowest tests") flag.BoolVar(&c.flags.histogram, "histogram", false, "print a histogram of test timings") flag.StringVar(&c.flags.tags, "tags", "", "comma-separated list of tags to filter results") + flag.BoolVar(&c.flags.aggregate, "aggregate", false, "aggregate times by test") return nil, nil } @@ -84,6 +87,44 @@ func (c *cmd) Run(ctx context.Context, cfg common.Config) error { } } + if c.flags.aggregate { + type Key struct { + Query query.Query + Status result.Status + Tags string + } + merged := map[Key]result.Result{} + for _, r := range results { + k := Key{ + Query: query.Query{ + Suite: r.Query.Suite, + Files: r.Query.Files, + Tests: r.Query.Tests, + Cases: "*", + }, + Status: r.Status, + Tags: result.TagsToString(r.Tags), + } + entry, exists := merged[k] + if exists { + entry.Duration += r.Duration + } else { + entry = result.Result{ + Query: k.Query, + Duration: r.Duration, + Status: r.Status, + Tags: r.Tags, + } + } + merged[k] = entry + } + + results = result.List{} + for _, r := range merged { + results = append(results, r) + } + } + // Sort the results with longest duration first sort.Slice(results, func(i, j int) bool { return results[i].Duration > results[j].Duration