@ -25,6 +25,8 @@
# include <benchmark/benchmark.h>
# include <benchmark/benchmark.h>
# include "absl/log/check.h"
# include "src/proto/grpc/testing/echo.grpc.pb.h"
# include "src/proto/grpc/testing/echo.grpc.pb.h"
# include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
# include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
# include "test/cpp/microbenchmarks/fullstack_fixtures.h"
# include "test/cpp/microbenchmarks/fullstack_fixtures.h"
@ -82,10 +84,10 @@ static void BM_StreamingPingPong(benchmark::State& state) {
bool ok ;
bool ok ;
int need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) ;
int need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
GPR_ASSERT ( ok ) ;
CHECK ( ok ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
@ -98,8 +100,8 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) | ( 1 < < 3 ) ;
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) | ( 1 < < 3 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
GPR_ASSERT ( ok ) ;
CHECK ( ok ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
// If server recv is complete, start the server send operation
// If server recv is complete, start the server send operation
@ -107,7 +109,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
response_rw . Write ( send_response , tag ( 3 ) ) ;
response_rw . Write ( send_response , tag ( 3 ) ) ;
}
}
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
@ -122,13 +124,13 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) ;
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
GPR_ASSERT ( recv_status . ok ( ) ) ;
CHECK ( recv_status . ok ( ) ) ;
}
}
}
}
@ -173,10 +175,10 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
bool ok ;
bool ok ;
int need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) ;
int need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
GPR_ASSERT ( ok ) ;
CHECK ( ok ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
@ -187,8 +189,8 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) | ( 1 < < 3 ) ;
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) | ( 1 < < 3 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
GPR_ASSERT ( ok ) ;
CHECK ( ok ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
// If server recv is complete, start the server send operation
// If server recv is complete, start the server send operation
@ -196,7 +198,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
response_rw . Write ( send_response , tag ( 3 ) ) ;
response_rw . Write ( send_response , tag ( 3 ) ) ;
}
}
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
}
}
@ -208,13 +210,13 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) ;
need_tags = ( 1 < < 0 ) | ( 1 < < 1 ) | ( 1 < < 2 ) ;
while ( need_tags ) {
while ( need_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( need_tags & ( 1 < < i ) ) ;
CHECK ( need_tags & ( 1 < < i ) ) ;
need_tags & = ~ ( 1 < < i ) ;
need_tags & = ~ ( 1 < < i ) ;
}
}
GPR_ASSERT ( recv_status . ok ( ) ) ;
CHECK ( recv_status . ok ( ) ) ;
}
}
fixture . reset ( ) ;
fixture . reset ( ) ;
@ -294,14 +296,14 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// initialized (async stream between client side and server side
// initialized (async stream between client side and server side
// established). It is necessary when client init metadata is
// established). It is necessary when client init metadata is
// coalesced
// coalesced
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
while ( static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ! = 0 ) {
while ( static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ! = 0 ) {
// In some cases tag:2 comes before tag:0 (write tag comes out
// In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0.
// first), this while loop is to make sure get tag:0.
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( await_tags & ( 1 < < i ) ) ;
CHECK ( await_tags & ( 1 < < i ) ) ;
await_tags & = ~ ( 1 < < i ) ;
await_tags & = ~ ( 1 < < i ) ;
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
}
}
}
}
@ -313,8 +315,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
await_tags | = ( 1 < < 5 ) ;
await_tags | = ( 1 < < 5 ) ;
while ( await_tags ! = 0 ) {
while ( await_tags ! = 0 ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
GPR_ASSERT ( ok ) ;
CHECK ( ok ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
// If server recv is complete, start the server send operation
// If server recv is complete, start the server send operation
@ -339,7 +341,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
}
}
}
}
GPR_ASSERT ( expect_tags & ( 1 < < i ) ) ;
CHECK ( expect_tags & ( 1 < < i ) ) ;
expect_tags & = ~ ( 1 < < i ) ;
expect_tags & = ~ ( 1 < < i ) ;
await_tags & = ~ ( 1 < < i ) ;
await_tags & = ~ ( 1 < < i ) ;
}
}
@ -364,12 +366,12 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
request_rw - > WritesDone ( tag ( 6 ) ) ;
request_rw - > WritesDone ( tag ( 6 ) ) ;
// wait for server call data structure(call_hook, etc.) to be
// wait for server call data structure(call_hook, etc.) to be
// initialized, since initial metadata is corked.
// initialized, since initial metadata is corked.
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
while ( static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ! = 0 ) {
while ( static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ! = 0 ) {
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( expect_tags & ( 1 < < i ) ) ;
CHECK ( expect_tags & ( 1 < < i ) ) ;
expect_tags & = ~ ( 1 < < i ) ;
expect_tags & = ~ ( 1 < < i ) ;
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
}
}
response_rw . Finish ( Status : : OK , tag ( 7 ) ) ;
response_rw . Finish ( Status : : OK , tag ( 7 ) ) ;
} else {
} else {
@ -382,13 +384,13 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
request_rw - > Finish ( & recv_status , tag ( 8 ) ) ;
request_rw - > Finish ( & recv_status , tag ( 8 ) ) ;
while ( expect_tags ) {
while ( expect_tags ) {
GPR_ASSERT ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
CHECK ( fixture - > cq ( ) - > Next ( & t , & ok ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
int i = static_cast < int > ( reinterpret_cast < intptr_t > ( t ) ) ;
GPR_ASSERT ( expect_tags & ( 1 < < i ) ) ;
CHECK ( expect_tags & ( 1 < < i ) ) ;
expect_tags & = ~ ( 1 < < i ) ;
expect_tags & = ~ ( 1 < < i ) ;
}
}
GPR_ASSERT ( recv_status . ok ( ) ) ;
CHECK ( recv_status . ok ( ) ) ;
}
}
}
}