buffering

Should I buffer the InputStream or the InputStreamReader?

梦想与她 提交于 2019-12-03 10:43:16
问题 What are the differences (if any) between the following two buffering approaches? Reader r1 = new BufferedReader(new InputStreamReader(in, "UTF-8"), bufferSize); Reader r2 = new InputStreamReader(new BufferedInputStream(in, bufferSize), "UTF-8"); 回答1: r1 is more efficient. The InputStreamReader itself doesn't have a large buffer. The BufferedReader can be set to have a larger buffer than InputStreamReader . The InputStreamReader in r2 would act as a bottleneck. In a nut: you should read the

Is it safe to disable buffering with stdout and stderr?

雨燕双飞 提交于 2019-12-03 09:27:02
问题 Sometimes we put some debug prints in our code this way printf("successfully reached at debug-point 1\n"); some code is here printf("successfully reached at debug-point 2"); After the last printf a segmentation fault occurs. Now in this condition only debug-point1 will be print on stdio debug-point 2 print was written to stdio buffer but its not flushed because it didn't get \n so we thinks that crash occur after debug-point1. To over come from this, if I disable buffering option with stdio

Simulate poor bandwidth in a testing environment (Mac OS X)?

喜欢而已 提交于 2019-12-03 07:43:44
问题 We have a customized Flash/HTML5 video player we use for users on our site. I'm currently fleshing out the experience for users who have 'suboptimal' bandwidth--basically we'd like the client side code to be able to detect poor user experience due to excessive buffering. I would like to test this "poor bandwidth" handling code in my local development environment. Does anyone know of good techniques for simulating "poor bandwidth" in a local environment for testing purposes? More specifically

How to stream a media file using PHP?

≡放荡痞女 提交于 2019-12-03 01:30:00
I am trying to build an application in which i have to stream the media files (audio and video) to the browser. I am reading the file through php and send the data to browser. I am using the following code. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Content-Type: {$file->getMimetype()}"); header("Content-Disposition: inline; filename=".$filename.";"); header("Content-Length: ".strlen($file_content)); echo $file_content; Every thing is working fine, except when i try to forward the video or audio,

Is it safe to disable buffering with stdout and stderr?

独自空忆成欢 提交于 2019-12-02 23:54:02
Sometimes we put some debug prints in our code this way printf("successfully reached at debug-point 1\n"); some code is here printf("successfully reached at debug-point 2"); After the last printf a segmentation fault occurs. Now in this condition only debug-point1 will be print on stdio debug-point 2 print was written to stdio buffer but its not flushed because it didn't get \n so we thinks that crash occur after debug-point1. To over come from this, if I disable buffering option with stdio and stderr stream like this way setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); Then

Simulate poor bandwidth in a testing environment (Mac OS X)?

一个人想着一个人 提交于 2019-12-02 22:39:36
We have a customized Flash/HTML5 video player we use for users on our site. I'm currently fleshing out the experience for users who have 'suboptimal' bandwidth--basically we'd like the client side code to be able to detect poor user experience due to excessive buffering. I would like to test this "poor bandwidth" handling code in my local development environment. Does anyone know of good techniques for simulating "poor bandwidth" in a local environment for testing purposes? More specifically I have my local browser connecting to a virtual machine with instances of uWSGI, nginx, and python

What is IO Stream Buffering?

不羁的心 提交于 2019-12-02 11:37:35
问题 I am unable to find the underlying concept of IO Stream Buffering and what does it mean. Any tutorials and links will be helpful. 回答1: Buffering is a fundamental part of software that handles input and output. The buffer holds data that is in between the software interface and the hardware interface, since hardware and software run at different speeds. A component which produces data can put it into a buffer, and later the buffer is "flushed" by sending the collected data to the next

Piping sometimes does not lead to immediate output

落爺英雄遲暮 提交于 2019-12-02 07:41:00
I observed a few times now that A | B | C may not lead to immediate output, although A is constantly producing output. I have no idea how this even may be possible. From my understanding all three processes ought to be working on the same time, putting their output into the next pipe (or stdout) and taking from the previous pipe when they are finished with one step. Here's an example where I am currently experiencing that: tcpflow -ec -i any port 8340 | tee second.flow | grep -i "\(</Manufacturer>\)\|\(</SerialNumber>\)" | awk -F'[<>]' '{print $3}' What is supposed to happen: I look at one

C# .NET - Buffer messages w/Timer

五迷三道 提交于 2019-12-02 07:16:15
问题 I need to implement a message buffering system that is also timed based. What I need to do is store instances of my class and then send them forward either when I reach 100 instances or when 1 minute has passed. Basically: List<Message> messages; public void GotNewMessage(Message msg) { messages.add(msg); if (messages.count() == 100 || timer.elapsed(1 minute)) { SendMessages(messages); messages.clear() } } I just can't seem to figure out how to implement this without an excessive use of locks

Java page flipping not supported on Mac OS?

守給你的承諾、 提交于 2019-12-02 06:24:41
问题 I'm hoping someone happens to have stumbled upon the following issue before. My Java application has graphics performance issues on Mac, so I made a simple test application (code below). When I run this on Windows, the console tells me: GraphicsConfiguration flipping? true BufferStrategy flipping? true When I run the exact same code on Mac OS, I get: GraphicsConfiguration flipping? true BufferStrategy flipping? false Does this mean that on Mac OS, page flipping is simply not supported in a