Are networks now faster than disks?

Here are some numbers that you are probably looking for, as quoted by Jeff Dean, a Google Fellow: Numbers Everyone Should Know L1 cache reference 0.5 ns Branch mispredict 5 ns L2 cache reference 7 ns Mutex lock/unlock 100 ns (25) Main memory reference 100 ns Compress 1K bytes with Zippy 10,000 ns (3,000) Send … Read more

Can anyone explain precisely what IOWait is?

I know it’s the time spent by the CPU waiting for a IO operations to complete, but what kind of IO operations precisely? What I am also not sure, is why it so important? Can’t the CPU just do something else while the IO operation completes, and then get back to processing data? Yes, the … Read more

Get an OutputStream into a String

I would use a ByteArrayOutputStream. And on finish you can call: or better: For the String constructor, the codepage can be a String or an instance of java.nio.charset.Charset. A possible value is java.nio.charset.StandardCharsets.UTF_8. The method toString() accepts only a String as a codepage parameter (stand Java 8).

How to open a file using the open with statement

Python allows putting multiple open() statements in a single with. You comma-separate them. Your code would then be: And no, you don’t gain anything by putting an explicit return at the end of your function. You can use return to exit early, but you had it at the end, and the function will exit without it. (Of course with functions that return … Read more