Skip to content

Commit 6f44ae8

Browse files
authored
metadata: add benchmark test for FromIncomingContext and ValueFromIncomingContext (#6117)
1 parent a1e657c commit 6f44ae8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

metadata/metadata_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,21 @@ func BenchmarkFromOutgoingContext(b *testing.B) {
335335
FromOutgoingContext(ctx)
336336
}
337337
}
338+
339+
func BenchmarkFromIncomingContext(b *testing.B) {
340+
md := Pairs("X-My-Header-1", "42")
341+
ctx := NewIncomingContext(context.Background(), md)
342+
b.ResetTimer()
343+
for n := 0; n < b.N; n++ {
344+
FromIncomingContext(ctx)
345+
}
346+
}
347+
348+
func BenchmarkValueFromIncomingContext(b *testing.B) {
349+
md := Pairs("X-My-Header-1", "42")
350+
ctx := NewIncomingContext(context.Background(), md)
351+
b.ResetTimer()
352+
for n := 0; n < b.N; n++ {
353+
ValueFromIncomingContext(ctx, "x-my-header-1")
354+
}
355+
}

0 commit comments

Comments
 (0)