partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 963333178afc9102e62f5f2b9b8d40d1aaedd0bf
parent 19ae0819525a27ea277ebe2900e22761cd4116c6
Author: Felicitus <felicitus@felicitus.org>
Date:   Sun, 25 Mar 2012 23:33:57 +0200

Added timing information to the service calls

Diffstat:
Msrc/frontend/rest.php | 5+++++
Msrc/frontend/service.php | 5+++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/frontend/rest.php b/src/frontend/rest.php @@ -10,6 +10,8 @@ PartKeepr::initialize(""); ServiceManager::sendHeaders(); +$timingStart = microtime(true); + /** * This script dispatches the request to the ServiceManager. * @@ -51,6 +53,7 @@ try { $response["status"] = "ok"; $response["success"] = true; $response["response"] = ServiceManager::call(); + $response["timing"] = microtime(true) - $timingStart; echo json_encode($response); @@ -60,6 +63,7 @@ try { $response["status"] = "error"; $response["success"] = false; $response["exception"] = $e->serialize(); + $response["timing"] = microtime(true) - $timingStart; echo json_encode($response); } catch (\Exception $e) { header('HTTP/1.0 400 Exception', false, 400); @@ -70,6 +74,7 @@ try { "message" => $e->getMessage(), "exception" => get_class($e), "backtrace" => $e->getTraceAsString()); + $response["timing"] = microtime(true) - $timingStart; echo json_encode($response); } diff --git a/src/frontend/service.php b/src/frontend/service.php @@ -10,6 +10,8 @@ PartKeepr::initialize(""); ServiceManager::sendHeaders(); +$timingStart = microtime(true); + try { $request = $_REQUEST; @@ -23,11 +25,13 @@ try { $response = array(); $response["status"] = "ok"; $response["response"] = ServiceManager::call($request); + $response["timing"] = microtime(true) - $timingStart; } catch (de\RaumZeitLabor\PartKeepr\Util\SerializableException $e) { $response = array(); $response["status"] = "error"; $response["exception"] = $e->serialize(); + $response["timing"] = microtime(true) - $timingStart; } catch (\Exception $e) { $response = array(); @@ -35,6 +39,7 @@ try { $response["exception"] = get_class($e); $response["message"] = $e->getMessage(); $response["backtrace"] = $e->getTraceAsString(); + $response["timing"] = microtime(true) - $timingStart; } if (array_key_exists("type", $_REQUEST) && strtolower($_REQUEST["type"]) == "jsonp") {