diff --git a/samples/client/petstore/php/swagger_client_profiling.output b/samples/client/petstore/php/swagger_client_profiling.output new file mode 100644 index 00000000000..487dd36f4da --- /dev/null +++ b/samples/client/petstore/php/swagger_client_profiling.output @@ -0,0 +1,31 @@ +0: NEW PETAPI => 0.050940 +0: ADD PET => 0.901768 +0: GET PET => 0.368627 +0: UPDATE PET => 0.366801 +0: DELETE PET => 0.368657 +1: NEW PETAPI => 0.000020 +1: ADD PET => 0.365229 +1: GET PET => 0.366909 +1: UPDATE PET => 0.366458 +1: DELETE PET => 0.365904 +2: NEW PETAPI => 0.000018 +2: ADD PET => 0.367664 +2: GET PET => 0.364671 +2: UPDATE PET => 0.365267 +2: DELETE PET => 0.366162 +3: NEW PETAPI => 0.000018 +3: ADD PET => 0.364907 +3: GET PET => 0.364156 +3: UPDATE PET => 0.366996 +3: DELETE PET => 0.366705 +4: NEW PETAPI => 0.000018 +4: ADD PET => 0.370373 +4: GET PET => 0.365455 +4: UPDATE PET => 0.365915 +4: DELETE PET => 0.368835 +5: NEW PETAPI => 0.000017 +5: ADD PET => 0.367148 +5: GET PET => 0.368994 +5: UPDATE PET => 0.368870 +5: DELETE PET => 0.367270 +6: FINISH diff --git a/samples/client/petstore/php/swagger_client_profiling.php b/samples/client/petstore/php/swagger_client_profiling.php new file mode 100644 index 00000000000..20a3d6b6bf5 --- /dev/null +++ b/samples/client/petstore/php/swagger_client_profiling.php @@ -0,0 +1,80 @@ + %f\n", $prof_names[$i], $prof_timing[$i+1]-$prof_timing[$i]); + } + echo "{$prof_names[$size-1]}\n"; +} + +$counter = 5; // run 5 times by default +$new_pet_id = 50001; // ID of pet that needs to be fetched + +for ($x = 0; $x <= $counter; $x++) { + try { + prof_flag("$x: NEW PETAPI"); + $pet_api = new Swagger\Client\Api\PetApi(); + + // ~~~ ADD PET ~~~ + prof_flag("$x: ADD PET"); + // add pet (post json) + $new_pet = new Swagger\Client\Model\Pet; + $new_pet->setId($new_pet_id); + $new_pet->setName("profiler"); + $new_pet->setStatus("available"); + $new_pet->setPhotoUrls(array("http://profiler.com")); + // new tag + $tag= new Swagger\Client\Model\Tag; + $tag->setId($new_pet_id); // use the same id as pet + $tag->setName("profile tag 1"); + // new category + $category = new Swagger\Client\Model\Category; + $category->setId($new_pet_id); // use the same id as pet + $category->setName("profile category 1"); + + $new_pet->setTags(array($tag)); + $new_pet->setCategory($category); + + // add a new pet (model) + $add_response = $pet_api->addPet($new_pet); + + // ~~~ GET PET ~~~ + prof_flag("$x: GET PET"); + $response = $pet_api->getPetById($new_pet_id); + + // ~~~ UPDATE PET WITH FORM ~~~ + prof_flag("$x: UPDATE PET"); + $response = $pet_api->updatePetWithForm($new_pet_id, "new profiler", "sold"); + + // ~~~ DELETE PET ~~~ + prof_flag("$x: DELETE PET"); + $response = $pet_api->deletePet($new_pet_id); + + } catch (Swagger\Client\ApiException $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; + echo 'HTTP response headers: ', print_r($e->getResponseHeaders(), true), "\n"; + echo 'HTTP response body: ', print_r($e->getResponseBody(), true), "\n"; + echo 'HTTP status code: ', $e->getCode(), "\n"; + } + +} + +prof_flag("$x: FINISH"); +prof_print(); + +