Skip to content

Commit

Permalink
http2: make TestCanonicalHeaderCacheGrowth faster
Browse files Browse the repository at this point in the history
Lower the number of iterations that this test runs for.
Reduces runtime with -race from 27s on my M1 Mac to 0.06s.

Change-Id: Ibd4b225277c79d9030c0a21b3077173a787cc4c1
Reviewed-on: https://go-review.googlesource.com/c/net/+/572656
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
neild committed Mar 20, 2024
1 parent 448c44f commit 3678185
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions http2/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4578,13 +4578,16 @@ func TestCanonicalHeaderCacheGrowth(t *testing.T) {
sc := &serverConn{
serveG: newGoroutineLock(),
}
const count = 1000
for i := 0; i < count; i++ {
h := fmt.Sprintf("%v-%v", base, i)
count := 0
added := 0
for added < 10*maxCachedCanonicalHeadersKeysSize {
h := fmt.Sprintf("%v-%v", base, count)
c := sc.canonicalHeader(h)
if len(h) != len(c) {
t.Errorf("sc.canonicalHeader(%q) = %q, want same length", h, c)
}
count++
added += len(h)
}
total := 0
for k, v := range sc.canonHeader {
Expand Down

0 comments on commit 3678185

Please sign in to comment.