diff --git a/metadata/metadata_test.go b/metadata/metadata_test.go index 57763cd6a973..9277f2d6c84f 100644 --- a/metadata/metadata_test.go +++ b/metadata/metadata_test.go @@ -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") + } +}