From c7c9f063391e72dd35c158a651450061b8ee52a3 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Fri, 27 Apr 2018 13:17:37 -0700 Subject: [PATCH 1/8] Init benchmark tests --- tests/qps/Logging/LoggingClientCrossTests.php | 88 +++++++++++++++++++ tests/qps/Logging/LoggingClientGRPC.php | 60 +++++++++++++ tests/qps/Logging/LoggingClientREST.php | 60 +++++++++++++ tests/qps/Logging/logging_grpc.php | 22 +++++ tests/qps/Logging/logging_rest.php | 21 +++++ tests/qps/benchmark.php | 11 +++ tests/qps/composer.json | 5 ++ tests/qps/run_fpm_test.sh | 8 ++ tests/qps/run_test.sh | 8 ++ 9 files changed, 283 insertions(+) create mode 100644 tests/qps/Logging/LoggingClientCrossTests.php create mode 100644 tests/qps/Logging/LoggingClientGRPC.php create mode 100644 tests/qps/Logging/LoggingClientREST.php create mode 100644 tests/qps/Logging/logging_grpc.php create mode 100644 tests/qps/Logging/logging_rest.php create mode 100644 tests/qps/benchmark.php create mode 100644 tests/qps/composer.json create mode 100644 tests/qps/run_fpm_test.sh create mode 100644 tests/qps/run_test.sh diff --git a/tests/qps/Logging/LoggingClientCrossTests.php b/tests/qps/Logging/LoggingClientCrossTests.php new file mode 100644 index 0000000000..41c3842336 --- /dev/null +++ b/tests/qps/Logging/LoggingClientCrossTests.php @@ -0,0 +1,88 @@ + [ + 'transport' => 'grpc' + ], + 'batchOptions' => ['batchSize' => 1] + ] + ); + + $restLogger = LoggingClient::psrBatchLogger( + 'perf-rest', + [ + 'clientConfig' => [ + 'transport' => 'rest' + ], + 'batchOptions' => ['batchSize' => 1] + ] + ); + + $warm_up_time = $arg_warm_up; + $benchmark_time = $arg_benchmark; + + $benchmark_count = 0; + $rest_latency_array = array(); + $grpc_latency_array = array(); + + // First latency + $start_time = microtime(true); + $grpcLogger->info('a'); + $grpc_first_latency = microtime(true) - $start_time; + + $start_time = microtime(true); + $restLogger->info('a'); + $rest_first_latency = microtime(true) - $start_time; + + // Warm up + $start_time = microtime(true); + echo "Start warmup...". PHP_EOL; + while(1) { + if (microtime(true) - $start_time > $warm_up_time) { + break; + } + $grpcLogger->info('a'); + $restLogger->info('a'); + } + // Benchmark + echo "Start benchmark...". PHP_EOL; + $start_time = microtime(true); + while(1) { + if (microtime(true) - $start_time > $benchmark_time) { + break; + } + $benchmark_count += 1; + + $grpc_start_time = microtime(true); + $grpcLogger->info('b'); + array_push($grpc_latency_array, microtime(true) - $grpc_start_time); + + $rest_start_time = microtime(true); + $restLogger->info('b'); + array_push($rest_latency_array, microtime(true) - $rest_start_time); + } + + echo "gRPC transport qps: ".($benchmark_count/array_sum($grpc_latency_array)).PHP_EOL; + echo "gRPC latency for first RPC:". $grpc_first_latency. PHP_EOL; + sort($grpc_latency_array); + print_stats("gRPC", $grpc_latency_array); + + echo "rest transport qps: ". ($benchmark_count/array_sum($rest_latency_array)). PHP_EOL; + echo "rest latency for first RPC:". $rest_first_latency. PHP_EOL; + sort($rest_latency_array); + print_stats("REST", $rest_latency_array); +} + +$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; +$arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; +qps_client_main($arg_warmup, $arg_benchmark); + diff --git a/tests/qps/Logging/LoggingClientGRPC.php b/tests/qps/Logging/LoggingClientGRPC.php new file mode 100644 index 0000000000..f39bdbed55 --- /dev/null +++ b/tests/qps/Logging/LoggingClientGRPC.php @@ -0,0 +1,60 @@ + [ + 'transport' => 'grpc' + ], + 'batchOptions' => ['batchSize' => 1] + ] + ); + + $warm_up_time = $arg_warm_up; + $benchmark_time = $arg_benchmark; + + $grpc_benchmark_count = 0; + $grpc_latency_array = array(); + $grpc_first_latency = 0; + + // gRPC QPS test begin + $start_time = microtime(true); + $grpcLogger->info('a'); + $grpc_first_latency = microtime(true) - $start_time; + $start_time = microtime(true); + echo "gRPC transport starts warmup...". PHP_EOL; + while(1) { + if (microtime(true) - $start_time > $warm_up_time) { + break; + } + $grpcLogger->info('a'); + } + echo "gRPC transport starts benchmark...". PHP_EOL; + $start_time = microtime(true); + while(1) { + $cur_time = microtime(true); + if ($cur_time - $start_time > $benchmark_time) { + break; + } + $grpcLogger->info('b'); + array_push($grpc_latency_array, microtime(true) - $cur_time); + $grpc_benchmark_count += 1; + } + + echo "gRPC transport qps: ".($grpc_benchmark_count/$benchmark_time).PHP_EOL; + echo "gRPC latency for first RPC:". $grpc_first_latency. PHP_EOL; + sort($grpc_latency_array); + print_stats("gRPC", $grpc_latency_array); +} + +$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; +$arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; +qps_client_main($arg_warmup, $arg_benchmark); + diff --git a/tests/qps/Logging/LoggingClientREST.php b/tests/qps/Logging/LoggingClientREST.php new file mode 100644 index 0000000000..304a1420db --- /dev/null +++ b/tests/qps/Logging/LoggingClientREST.php @@ -0,0 +1,60 @@ + [ + 'transport' => 'rest' + ], + 'batchOptions' => ['batchSize' => 1] + ] + ); + + $warm_up_time = $arg_warm_up; + $benchmark_time = $arg_benchmark; + + $rest_benchmark_count = 0; + $rest_latency_array = array(); + $rest_first_latency = 0; + + // REST QPS test begin + $start_time = microtime(true); + $restLogger->info('a'); + $rest_first_latency = microtime(true) - $start_time; + $start_time = microtime(true); + echo "rest transport starts warmup...". PHP_EOL; + while(1) { + if (microtime(true) - $start_time > $warm_up_time) { + break; + } + $restLogger->info('a'); + } + echo "rest transport starts benchmark...". PHP_EOL; + $start_time = microtime(true); + while(1) { + $cur_time = microtime(true); + if ($cur_time - $start_time > $benchmark_time) { + break; + } + $restLogger->info('b'); + array_push($rest_latency_array, microtime(true) - $cur_time); + $rest_benchmark_count += 1; + } + + echo "rest transport qps: ". ($rest_benchmark_count/$benchmark_time). PHP_EOL; + echo "rest latency for first RPC:". $rest_first_latency. PHP_EOL; + sort($rest_latency_array); + print_stats("REST", $rest_latency_array); +} + +$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; +$arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; +qps_client_main($arg_warmup, $arg_benchmark); + diff --git a/tests/qps/Logging/logging_grpc.php b/tests/qps/Logging/logging_grpc.php new file mode 100644 index 0000000000..75ba1a7559 --- /dev/null +++ b/tests/qps/Logging/logging_grpc.php @@ -0,0 +1,22 @@ + [ + 'transport' => 'grpc' + ], + 'batchOptions' => ['batchSize' => 1] + ] +); + +$start_time = microtime(true); +$grpcLogger->info('s'); +$first_latency = microtime(true) - $start_time; +echo "rest latency for first RPC:". $first_latency. PHP_EOL; +file_put_contents('logs_grpc.txt', $first_latency.PHP_EOL , FILE_APPEND | LOCK_EX); + diff --git a/tests/qps/Logging/logging_rest.php b/tests/qps/Logging/logging_rest.php new file mode 100644 index 0000000000..7bfd6d16c2 --- /dev/null +++ b/tests/qps/Logging/logging_rest.php @@ -0,0 +1,21 @@ + [ + 'transport' => 'rest' + ], + 'batchOptions' => ['batchSize' => 1] + ] +); + +$start_time = microtime(true); +$restLogger->info('e'); +$first_latency = microtime(true) - $start_time; +echo "rest latency for first RPC:". $first_latency. PHP_EOL; +file_put_contents('logs_rest.txt', $first_latency.PHP_EOL , FILE_APPEND | LOCK_EX); diff --git a/tests/qps/benchmark.php b/tests/qps/benchmark.php new file mode 100644 index 0000000000..4c4823fcb4 --- /dev/null +++ b/tests/qps/benchmark.php @@ -0,0 +1,11 @@ + Date: Tue, 1 May 2018 14:05:15 -0700 Subject: [PATCH 2/8] update measuring the first RPC including initializing the client --- tests/qps/Logging/logging_grpc.php | 2 +- tests/qps/Logging/logging_rest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qps/Logging/logging_grpc.php b/tests/qps/Logging/logging_grpc.php index 75ba1a7559..3870af8595 100644 --- a/tests/qps/Logging/logging_grpc.php +++ b/tests/qps/Logging/logging_grpc.php @@ -4,6 +4,7 @@ putenv("GOOGLE_APPLICATION_CREDENTIALS=./grpcwebtesting_key.json"); require_once './vendor/autoload.php'; +$start_time = microtime(true); $grpcLogger = LoggingClient::psrBatchLogger( 'perf-grpc', [ @@ -14,7 +15,6 @@ ] ); -$start_time = microtime(true); $grpcLogger->info('s'); $first_latency = microtime(true) - $start_time; echo "rest latency for first RPC:". $first_latency. PHP_EOL; diff --git a/tests/qps/Logging/logging_rest.php b/tests/qps/Logging/logging_rest.php index 7bfd6d16c2..97595350a7 100644 --- a/tests/qps/Logging/logging_rest.php +++ b/tests/qps/Logging/logging_rest.php @@ -4,6 +4,7 @@ putenv("GOOGLE_APPLICATION_CREDENTIALS=./grpcwebtesting_key.json"); require_once './vendor/autoload.php'; +$start_time = microtime(true); $restLogger = LoggingClient::psrBatchLogger( 'perf-rest', [ @@ -14,7 +15,6 @@ ] ); -$start_time = microtime(true); $restLogger->info('e'); $first_latency = microtime(true) - $start_time; echo "rest latency for first RPC:". $first_latency. PHP_EOL; From 03ed050c967e9f4cba9dfb76723c2d7d8b245b86 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Tue, 1 May 2018 15:41:12 -0700 Subject: [PATCH 3/8] update composer.json --- tests/qps/composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qps/composer.json b/tests/qps/composer.json index 1feb4d9ab1..371b0ee678 100644 --- a/tests/qps/composer.json +++ b/tests/qps/composer.json @@ -1,5 +1,7 @@ { "require": { - "google/cloud": "^0.56.0" + "google/cloud": "^0.62.0", + "ext-json": "*", + "ext-protobuf": "*" } } From e414f96b1a3095221c66e2e6bfba653830041a38 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Wed, 2 May 2018 14:37:25 -0700 Subject: [PATCH 4/8] add payload --- tests/qps/Logging/LoggingClientCrossTests.php | 9 +++++---- tests/qps/benchmark.php | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/qps/Logging/LoggingClientCrossTests.php b/tests/qps/Logging/LoggingClientCrossTests.php index 41c3842336..cfe183b618 100644 --- a/tests/qps/Logging/LoggingClientCrossTests.php +++ b/tests/qps/Logging/LoggingClientCrossTests.php @@ -4,7 +4,7 @@ require dirname(__FILE__).'/../benchmark.php'; use Google\Cloud\Logging\LoggingClient; -function qps_client_main($arg_warm_up, $arg_benchmark) +function qps_client_main($arg_warm_up, $arg_benchmark, $payload) { // Disable the batch so each request stands for a RPC $grpcLogger = LoggingClient::psrBatchLogger( @@ -36,11 +36,11 @@ function qps_client_main($arg_warm_up, $arg_benchmark) // First latency $start_time = microtime(true); - $grpcLogger->info('a'); + $grpcLogger->info(generate_string($payload)); $grpc_first_latency = microtime(true) - $start_time; $start_time = microtime(true); - $restLogger->info('a'); + $restLogger->info(generate_string($payload)); $rest_first_latency = microtime(true) - $start_time; // Warm up @@ -84,5 +84,6 @@ function qps_client_main($arg_warm_up, $arg_benchmark) $arg_warmup = !empty($argv[1]) ? $argv[1] : 20; $arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; -qps_client_main($arg_warmup, $arg_benchmark); +$payload = !empty($argv[3]) ? $argv[3] : 1; +qps_client_main($arg_warmup, $arg_benchmark, $payload); diff --git a/tests/qps/benchmark.php b/tests/qps/benchmark.php index 4c4823fcb4..567f61e34d 100644 --- a/tests/qps/benchmark.php +++ b/tests/qps/benchmark.php @@ -9,3 +9,16 @@ function print_stats($name, $stats) echo "90% latency :". $stats[count($stats)*0.9]. PHP_EOL; echo "99% latency :". $stats[min(count($stats)*0.99, count($stats) - 1)]. PHP_EOL; } + +function generate_string($size) +{ + $seed = str_split('abcdefghijklmnopqrstuvwxyz' + .'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + .'0123456789!@#$%^&*()'); + $str_res = '' + for($i=0; $i<$size; $i++) { + $k = rand(0,71); + $str_res .= $seed[$k]; + } + return $str_res; +} \ No newline at end of file From 2c2c70ff46ec17188bf8d176b5437b41bbb306e3 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Wed, 2 May 2018 14:44:56 -0700 Subject: [PATCH 5/8] add ext-curl --- tests/qps/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qps/composer.json b/tests/qps/composer.json index 371b0ee678..e8980d7990 100644 --- a/tests/qps/composer.json +++ b/tests/qps/composer.json @@ -2,6 +2,7 @@ "require": { "google/cloud": "^0.62.0", "ext-json": "*", - "ext-protobuf": "*" + "ext-protobuf": "*", + "ext-curl": "*" } } From a831f7dfaab3eef359589cef203a2f40c0a9b701 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Wed, 2 May 2018 14:46:39 -0700 Subject: [PATCH 6/8] Write different logs. fix missing ; --- tests/qps/Logging/LoggingClientCrossTests.php | 10 ++++++---- tests/qps/benchmark.php | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/qps/Logging/LoggingClientCrossTests.php b/tests/qps/Logging/LoggingClientCrossTests.php index cfe183b618..c01a4ee1aa 100644 --- a/tests/qps/Logging/LoggingClientCrossTests.php +++ b/tests/qps/Logging/LoggingClientCrossTests.php @@ -36,11 +36,11 @@ function qps_client_main($arg_warm_up, $arg_benchmark, $payload) // First latency $start_time = microtime(true); - $grpcLogger->info(generate_string($payload)); + $grpcLogger->info("a"); $grpc_first_latency = microtime(true) - $start_time; $start_time = microtime(true); - $restLogger->info(generate_string($payload)); + $restLogger->info("b"); $rest_first_latency = microtime(true) - $start_time; // Warm up @@ -62,12 +62,14 @@ function qps_client_main($arg_warm_up, $arg_benchmark, $payload) } $benchmark_count += 1; + $msg_grpc = generate_string($payload); $grpc_start_time = microtime(true); - $grpcLogger->info('b'); + $grpcLogger->info($msg_grpc); array_push($grpc_latency_array, microtime(true) - $grpc_start_time); + $msg_rest = generate_string($payload); $rest_start_time = microtime(true); - $restLogger->info('b'); + $restLogger->info($msg_rest); array_push($rest_latency_array, microtime(true) - $rest_start_time); } diff --git a/tests/qps/benchmark.php b/tests/qps/benchmark.php index 567f61e34d..7a12e994e4 100644 --- a/tests/qps/benchmark.php +++ b/tests/qps/benchmark.php @@ -15,10 +15,10 @@ function generate_string($size) $seed = str_split('abcdefghijklmnopqrstuvwxyz' .'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .'0123456789!@#$%^&*()'); - $str_res = '' + $str_res = ''; for($i=0; $i<$size; $i++) { $k = rand(0,71); $str_res .= $seed[$k]; } return $str_res; -} \ No newline at end of file +} From 8ec2bdf3752869e0357ae885199ef73433f9bfab Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Wed, 2 May 2018 16:02:19 -0700 Subject: [PATCH 7/8] remove some tests, only leave cross test --- tests/qps/Logging/LoggingClientGRPC.php | 60 ------------------------- tests/qps/Logging/LoggingClientREST.php | 60 ------------------------- tests/qps/run_test.sh | 2 - 3 files changed, 122 deletions(-) delete mode 100644 tests/qps/Logging/LoggingClientGRPC.php delete mode 100644 tests/qps/Logging/LoggingClientREST.php diff --git a/tests/qps/Logging/LoggingClientGRPC.php b/tests/qps/Logging/LoggingClientGRPC.php deleted file mode 100644 index f39bdbed55..0000000000 --- a/tests/qps/Logging/LoggingClientGRPC.php +++ /dev/null @@ -1,60 +0,0 @@ - [ - 'transport' => 'grpc' - ], - 'batchOptions' => ['batchSize' => 1] - ] - ); - - $warm_up_time = $arg_warm_up; - $benchmark_time = $arg_benchmark; - - $grpc_benchmark_count = 0; - $grpc_latency_array = array(); - $grpc_first_latency = 0; - - // gRPC QPS test begin - $start_time = microtime(true); - $grpcLogger->info('a'); - $grpc_first_latency = microtime(true) - $start_time; - $start_time = microtime(true); - echo "gRPC transport starts warmup...". PHP_EOL; - while(1) { - if (microtime(true) - $start_time > $warm_up_time) { - break; - } - $grpcLogger->info('a'); - } - echo "gRPC transport starts benchmark...". PHP_EOL; - $start_time = microtime(true); - while(1) { - $cur_time = microtime(true); - if ($cur_time - $start_time > $benchmark_time) { - break; - } - $grpcLogger->info('b'); - array_push($grpc_latency_array, microtime(true) - $cur_time); - $grpc_benchmark_count += 1; - } - - echo "gRPC transport qps: ".($grpc_benchmark_count/$benchmark_time).PHP_EOL; - echo "gRPC latency for first RPC:". $grpc_first_latency. PHP_EOL; - sort($grpc_latency_array); - print_stats("gRPC", $grpc_latency_array); -} - -$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; -$arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; -qps_client_main($arg_warmup, $arg_benchmark); - diff --git a/tests/qps/Logging/LoggingClientREST.php b/tests/qps/Logging/LoggingClientREST.php deleted file mode 100644 index 304a1420db..0000000000 --- a/tests/qps/Logging/LoggingClientREST.php +++ /dev/null @@ -1,60 +0,0 @@ - [ - 'transport' => 'rest' - ], - 'batchOptions' => ['batchSize' => 1] - ] - ); - - $warm_up_time = $arg_warm_up; - $benchmark_time = $arg_benchmark; - - $rest_benchmark_count = 0; - $rest_latency_array = array(); - $rest_first_latency = 0; - - // REST QPS test begin - $start_time = microtime(true); - $restLogger->info('a'); - $rest_first_latency = microtime(true) - $start_time; - $start_time = microtime(true); - echo "rest transport starts warmup...". PHP_EOL; - while(1) { - if (microtime(true) - $start_time > $warm_up_time) { - break; - } - $restLogger->info('a'); - } - echo "rest transport starts benchmark...". PHP_EOL; - $start_time = microtime(true); - while(1) { - $cur_time = microtime(true); - if ($cur_time - $start_time > $benchmark_time) { - break; - } - $restLogger->info('b'); - array_push($rest_latency_array, microtime(true) - $cur_time); - $rest_benchmark_count += 1; - } - - echo "rest transport qps: ". ($rest_benchmark_count/$benchmark_time). PHP_EOL; - echo "rest latency for first RPC:". $rest_first_latency. PHP_EOL; - sort($rest_latency_array); - print_stats("REST", $rest_latency_array); -} - -$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; -$arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; -qps_client_main($arg_warmup, $arg_benchmark); - diff --git a/tests/qps/run_test.sh b/tests/qps/run_test.sh index e0227acad2..9f62ee5e75 100644 --- a/tests/qps/run_test.sh +++ b/tests/qps/run_test.sh @@ -1,8 +1,6 @@ #!/bin/bash # LoggingClient -php -d extension=grpc.so -d extension=protobuf.so Logging/LoggingClientGRPC.php 20 40 -php -d extension=protobuf.so Logging/LoggingClientREST.php 20 40 php -d extension=grpc.so -d extension=protobuf.so Logging/LoggingClientCrossTests.php 40 80 From b1ce3d2f1ce61129778ab4e78a21dab9001d1889 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Thu, 3 May 2018 10:37:35 -0700 Subject: [PATCH 8/8] different payload should also be measured crossly; 1k as default --- tests/qps/Logging/LoggingClientCrossTests.php | 59 ++++++++++--------- tests/qps/run_test.sh | 2 +- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/tests/qps/Logging/LoggingClientCrossTests.php b/tests/qps/Logging/LoggingClientCrossTests.php index c01a4ee1aa..845edf2fb8 100644 --- a/tests/qps/Logging/LoggingClientCrossTests.php +++ b/tests/qps/Logging/LoggingClientCrossTests.php @@ -33,15 +33,10 @@ function qps_client_main($arg_warm_up, $arg_benchmark, $payload) $benchmark_count = 0; $rest_latency_array = array(); $grpc_latency_array = array(); - - // First latency - $start_time = microtime(true); - $grpcLogger->info("a"); - $grpc_first_latency = microtime(true) - $start_time; - - $start_time = microtime(true); - $restLogger->info("b"); - $rest_first_latency = microtime(true) - $start_time; + for ($i = 0; $i < count($payload); $i++) { + $rest_latency_array[$i] = array(); + $grpc_latency_array[$i] = array(); + } // Warm up $start_time = microtime(true); @@ -61,31 +56,41 @@ function qps_client_main($arg_warm_up, $arg_benchmark, $payload) break; } $benchmark_count += 1; + for ($i = 0; $i < count($payload); $i++) { + $payload_size = $payload[$i]; + $msg_grpc = generate_string($payload_size); + $msg_rest = generate_string($payload_size); - $msg_grpc = generate_string($payload); - $grpc_start_time = microtime(true); - $grpcLogger->info($msg_grpc); - array_push($grpc_latency_array, microtime(true) - $grpc_start_time); + $grpc_start_time = microtime(true); + $grpcLogger->info($msg_grpc); + array_push($grpc_latency_array[$i], microtime(true) - $grpc_start_time); - $msg_rest = generate_string($payload); - $rest_start_time = microtime(true); - $restLogger->info($msg_rest); - array_push($rest_latency_array, microtime(true) - $rest_start_time); + $rest_start_time = microtime(true); + $restLogger->info($msg_rest); + array_push($rest_latency_array[$i], microtime(true) - $rest_start_time); + } } - echo "gRPC transport qps: ".($benchmark_count/array_sum($grpc_latency_array)).PHP_EOL; - echo "gRPC latency for first RPC:". $grpc_first_latency. PHP_EOL; - sort($grpc_latency_array); - print_stats("gRPC", $grpc_latency_array); + for ($i = 0; $i < count($payload); $i++) { + echo "=====================". PHP_EOL; + echo "payload: ". $payload[$i]. PHP_EOL; + echo "gRPC transport qps: " . ($benchmark_count / array_sum($grpc_latency_array[$i])) . PHP_EOL; + sort($grpc_latency_array[$i]); + print_stats("gRPC", $grpc_latency_array[$i]); - echo "rest transport qps: ". ($benchmark_count/array_sum($rest_latency_array)). PHP_EOL; - echo "rest latency for first RPC:". $rest_first_latency. PHP_EOL; - sort($rest_latency_array); - print_stats("REST", $rest_latency_array); + echo "rest transport qps: " . ($benchmark_count / array_sum($rest_latency_array[$i])) . PHP_EOL; + sort($rest_latency_array[$i]); + print_stats("REST", $rest_latency_array[$i]); + } } -$arg_warmup = !empty($argv[1]) ? $argv[1] : 20; +$arg_warmup = !empty($argv[1]) ? $argv[1] : 2; $arg_benchmark = !empty($argv[2]) ? $argv[2] : 40; -$payload = !empty($argv[3]) ? $argv[3] : 1; +$payload = array(); +if(!empty($argv[3])) { + $payload = array_map('intval', explode(',', $argv[3])); +} else { + $payload = array(1, 10, 100, 1024, 10240); +} qps_client_main($arg_warmup, $arg_benchmark, $payload); diff --git a/tests/qps/run_test.sh b/tests/qps/run_test.sh index 9f62ee5e75..4740d013af 100644 --- a/tests/qps/run_test.sh +++ b/tests/qps/run_test.sh @@ -1,6 +1,6 @@ #!/bin/bash # LoggingClient -php -d extension=grpc.so -d extension=protobuf.so Logging/LoggingClientCrossTests.php 40 80 +php -d extension=grpc.so -d extension=protobuf.so Logging/LoggingClientCrossTests.php 40 80 1024