简体   繁体   English

PHP Soap客户端请求时间测量

[英]PHP Soap client request time measurement

I want to get for each call I do with Soap client a total time for the request. 我希望获得与Soap客户端进行的每个呼叫的total time请求total time

I've searched everywhere for such in-the-box solution like curl_getinfo but nothing. 我到处都在搜索像curl_getinfo这样的现成解决方案,但是什么也没有。

Tried to log the __getLastResponseHeaders() and __getLastRequestHeaders() - no info there about that (and yes- I had enabled the trace). 试图记录__getLastResponseHeaders()__getLastRequestHeaders() -那里没有关于它的信息(是的,我已经启用了跟踪)。

Is there another solution but to use microtime for measuring the request time? 是否有另一种解决方案,但使用microtime用于测量请求时间?

Well PHP works in sync way anyways. 不管怎么说,PHP都能以同步方式工作。 it wont continue untill it has completed a function. 在完成功能之前,它不会继续。

Just add time mes in your code. 只需在您的代码中添加时间。

// Start of code
$now = microtime(true); // Gets microseconds

// Rest of code

// End of code
echo "Time Elapsed: ".(microtime(true) - $now)."s";

You can pretty much use this anywhere. 您几乎可以在任何地方使用它。 or you could do excact curl req via command line: time curl http://www.example.com/ It times the whole request, including network latency. 或者您可以通过命令行执行精确的curl req: time curl http://www.example.com/它乘以整个请求的时间,包括网络延迟。

In a commend line of PHP file would be time php dancebattle.php 在PHP文件的推荐行中将是time php dancebattle.php

There is a general liberally ment for that aswell: https://github.com/fotuzlab/appgati ( it unix only tho, so it wont work on windows) 对此也有一个一般的建议: https : //github.com/fotuzlab/appgati (它仅在Unix上使用,因此在Windows上不起作用)

Anyways, the best and most easy to use is microtime php built in function. 无论如何,最好和最容易使用的是内置的microtime php函数。 I would personally stick with that. 我个人会坚持这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM