Posts

Showing posts from January, 2011

Memory was cheap but now its cheaper.

Its my impression that hardware costs tend to fall in January. Possibly due to lower demand... In any case I have had a look at the cost of servers with large amounts of memory and can see they are cheaper than the system I bought a year ago. Memory in GB Cost with 2+ GHz processors 24 £1,800 64 £4,200 1024 £53,000 Imagine running a JVM using close to 1 TB of memory of commodity hardware. :D

Using unsigned values in Java

A common question on stackoverflow is; How do I use unsigned numbers in Java? The short answer is that for most operations it makes no difference whether the number is signed or unsigned. However to make this clear and to handle the operations where being unsigned makes a difference, I have create a simple helper class Unsigned available on Google Code.

How *slow* can you read/write files in Java?

A common question on stackoverflow is; Why is reading/writing from a file in Java so slow? What is the fastest way? The discussion often compares NIO vs IO. However the read/writing is usually not the problem and the comparison has little importance. To demonstrate this, I am going to show the one of the simplest/slowest ways to read/write text which is slower than writing binary in NIO or IO but is fast enough IMHO for most use cases. The following program prints the following output. Wrote 101 MB/s. Read 109 MB/s. If 100 MB/s is fast enough, it really shouldn't matter which way you read/write data to disk. Note: For very large files, this result depends on the speed and configuration of your disks. In which case, you need to look at how your hardware, don't blame your software. // generate a string with full of A's char[] chars = new char[40]; Arrays.fill(chars, 'A'); String text = new String(chars); final File file = new File("/tmp/a.txt"