简体   繁体   English

我想在php中获取流

[英]I'm trying to get streams in php

So I've been on the whole researching techniques for better architecture and run time performance and streams have come up, reading through the documentation and a blog post I am now only dimly aware of using streams. 所以我一直在研究更好的架构和运行时性能的整个研究技术和流程,阅读文档和博客文章,我现在只是模糊地使用流。 My question is how would you explain streams,streamWrappers, and what's the cleanest OO implementation ? 我的问题是你如何解释stream,streamWrappers以及什么是最干净的OO实现?

I currently think that I might be able to use a stream function object that could improve the speed of returning application views, and client request handling. 我目前认为我可能能够使用流函数对象,可以提高返回应用程序视图和客户端请求处理的速度。 but I don't know how. 但我不知道怎么做。

anyway... does anyone understand what I'm getting at? 无论如何...有谁知道我得到了什么? I don't think it's neccesisarily trivial. 我认为这不是一件小事。

Unless your 'views' are huge, you will see very little benefit from streams. 除非你的“观点”很大,否则你会看到来自溪流的好处。

So there's two possibilities here, from my perspective: 从我的角度来看,这里有两种可能性:

  1. You think you could make things even faster than they are 你认为你可以让事情变得更快
  2. You actually have a performance issue, and think you can make things faster with streams. 实际上你遇到了性能问题,并认为你可以用流来加快速度。

If you are in category #1, don't look in this direction. 如果您属于#1类,请不要朝这个方向看。 Unless you are dealing with bigger files, this will be relevant. 除非您正在处理更大的文件,否则这将是相关的。

If you are in category #2, then there's is an extremely small chance that your bottleneck is in your view. 如果您属于#2类别,那么您的瓶颈在您的视野中的可能性极小。 Generally with PHP applications this is one of the fastest parts of your application. 通常使用PHP应用程序,这是应用程序中最快的部分之一。

Instead you should install xdebug, start profiling and analyze your code with Webgrind/Valgrind/KCachegrind/WinCacheGrind. 相反,您应该安装xdebug,使用Webgrind / Valgrind / KCachegrind / WinCacheGrind开始分析和分析您的代码。 This will give you a ton of information and tell you exactly where your problem is. 这将为您提供大量信息,并告诉您问题的具体位置。

Streams are simple enough really, being only a resource object that acts like a stream: readable and writable in linear fashion, so I/we are dealing with streams if only obliquely every time we code something that specifies what and how we serve in response to requests. Streams真的很简单,只是一个像流一样的资源对象:可读和可写的线性方式,所以我/我们正在处理流,如果只是倾斜地每次我们编写一些东西,指定我们服务的内容和方式以响应要求。 While there's a lot more to it than that there's a pear extension named pecl_http which really simplifies working http. 虽然还有很多东西,但是有一个名为pecl_http的梨扩展,它真正简化了工作http。

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

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