计算触发的文件请求数
是否可以在 apache debian Web 服务器上使用 PHP(5) 或其他 Linux 工具来获取单个 http 请求的文件请求? 出于性能原因,我想将它们与我的蛋糕应用程序的缓存“版本”进行比较。
在某些视图中,非缓存的数量可能超过 100。 最多只缓存 10 个(希望如此)。
afaik 有 3 个主要文件功能: file_get_contents()、file() 和手动 fopen() 等,
但我无法覆盖它们,因此我无法在其中放置 logRequest() 函数。 还有其他办法吗?将回调附加到函数?拦截文件请求?
Is it possible with PHP(5) or other Linux tools on an apache debian webserver to get the file requests a single http request made?
for performance reasons i would like to compare them with the cached "version" of my cake app.
non-cached that might be over 100 in some views.
cached only up to 10 (hopefully).
afaik there are 3 main file functions:
file_get_contents(), file() and the manual fopen() etc
but i cannot override them so i cannot place a logRequest() function in them.
is there any other way? attaching callbacks to functions? intercepting the file requests?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你可以看看 xdebug - function trace
这个建议似乎并不直观,但是一旦你有了 xdebug, 安装并启用后,您可以使用各种配置将分析保存到磁盘文件中,并可以稍后检索它。例如不同 URL 的分析结果保存到不同的磁盘文件中。
要监视文件系统相关功能,您可以对文本文件进行解析(分析结果)并计算可匹配的功能(可编程或手动)
This suggestion does not seems intuitive, but you can take look on xdebug - function trace
Once you have xdebug installed and enabled, you can using all sort of configuration to save the profiling into a disk file and you can retrieve it later. Such as profiling results for different URL save into different disk file.
To monitoring file system related functions, you can do a parse of the text file(profiling results) and do a count of matchable functions (programmable or manually)
我的方法是创建一个自定义函数来包装您需要的函数。
只需将所有对 file_get_contents 的调用替换为 custom_file_get_contents 即可。这只是一个基本的例子,但你已经明白了。
旁注,如果您想计算脚本已包含(或需要)的文件数量,请参阅 get_included_files()
The way I would do it would be to create a custom function that wraps around the one you need.
And just replace all of your calls to file_get_contents with custom_file_get_contents. This is just a rudimentary example, but you get the idea.
Side note, if you want to count how many files your script has included (or required), see get_included_files()
您可以使用 Xdebug 记录所有函数调用
You can use Xdebug to log all function calls
有趣的问题。我将从 stream_wrapper 开始......尝试用自定义类替换它们。
Interesting question. I'd start with the stream_wrapper ... try to replace them with custom classes.
有一个名为 ADB(高级 PHP 调试器)的 pecl 扩展,它有两个对于这样的 cse 非常有用的函数 - override_function() 和 rename_function()。你可以这样做:
看起来 ADB 也很容易安装。
请参阅http://www.php.net/manual/en/book.apd。 php
There is a pecl extention called ADB (Advanced PHP Debugger) that has tow functions that would be very useful for a cse like this - override_function() and rename_function(). You could do something like this:
It looks like ADB is pretty easy to install, too.
See http://www.php.net/manual/en/book.apd.php