문제

That's about it. Is OB heavier than including a file?

도움이 되었습니까?

해결책

Output buffering works in RAM. Hitting the filesystem may only hit RAM (cache), but it has the potential to hit the disks. Any time you hit the disks, you're looking at at least an order of magnitude of slowness compared to straight RAM access.

다른 팁

I'd say depends on what's expensive on your system... if you absolutely must use the smallest amount of memory possible, then writing directly to disk may be your only option, although the underlying system's implementation of a 'disk write' will still write out in chunks when it can, since you're probably not calling 'write' for each character.

In the end, buffering within reason is faster... the easiest way to test is by writing out a large string of characters, one character at a time, then the string in a few reasonable chunks.

With that in mind, I can't think of why you wouldn't buffer your output at least somewhat! If all you're doing is copying a file from one place to another, using a system call (if available) is probably much faster than it would be reading, buffering and writing in PHP.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top