Skip to content

Instantly share code, notes, and snippets.

@dwsupplee
Created April 27, 2018 18:12
Show Gist options
  • Save dwsupplee/3ec399fb43b30218ec08cb7846a72104 to your computer and use it in GitHub Desktop.
Save dwsupplee/3ec399fb43b30218ec08cb7846a72104 to your computer and use it in GitHub Desktop.
<?php
$s1 = microtime(true);
for ($i = 0; $i < 20; $i++) {
exec('php gapic.php');
}
print microtime(true) - $s1 . PHP_EOL;
$s2 = microtime(true);
for ($i = 0; $i < 20; $i++) {
exec('php non-gapic.php');
}
print microtime(true) - $s2 . PHP_EOL;
<?php
require 'vendor/autoload.php';
use Google\Cloud\Logging\LoggingClient;
// This will choose the "gRPC" connection, which is really jut a GAPIC connection.
// To have the GAPIC use REST override this property to "rest": https://github.com/GoogleCloudPlatform/google-cloud-php/blob/master/Core/src/GrpcTrait.php#L105
$client = new LoggingClient([
'transport' => 'grpc'
]);
$client->logger('test_logs_gapic')->write(['some' => 'test data'], [
'labels' => [
'test' => 'label'
],
'operation' => [
'id' => 'myid'
],
'httpRequest' => [
'requestMethod' => 'GET'
]
]);
<?php
require 'vendor/autoload.php';
use Google\Cloud\Logging\LoggingClient;
$client = new LoggingClient([
'transport' => 'rest'
]);
$client->logger('test_logs_non_gapic')->write(['some' => 'test data'], [
'labels' => [
'test' => 'label'
],
'operation' => [
'id' => 'myid'
],
'httpRequest' => [
'requestMethod' => 'GET'
]
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment