Skip to content

Commit

Permalink
metadata: add benchmark test for FromIncomingContext and ValueFromInc…
Browse files Browse the repository at this point in the history
…omingContext (#6117)
  • Loading branch information
wenxuwan authored Mar 15, 2023
1 parent a1e657c commit 6f44ae8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,21 @@ func BenchmarkFromOutgoingContext(b *testing.B) {
FromOutgoingContext(ctx)
}
}

func BenchmarkFromIncomingContext(b *testing.B) {
md := Pairs("X-My-Header-1", "42")
ctx := NewIncomingContext(context.Background(), md)
b.ResetTimer()
for n := 0; n < b.N; n++ {
FromIncomingContext(ctx)
}
}

func BenchmarkValueFromIncomingContext(b *testing.B) {
md := Pairs("X-My-Header-1", "42")
ctx := NewIncomingContext(context.Background(), md)
b.ResetTimer()
for n := 0; n < b.N; n++ {
ValueFromIncomingContext(ctx, "x-my-header-1")
}
}

0 comments on commit 6f44ae8

Please sign in to comment.