Timer.java is a program that uncovers the advantages of using cache memory by using java arrays to demonstrate the time difference between the processor going to memory to get data or by going to cache memory to get data. This download is a zip file containing the .java file so that people can see the code and compile it, or modify it themselves if they choose, the .class file, so that people don’t have to compile it, and an academic paper describing the project in detail. Here is a link to the paper, “What a Difference a Cache Makes”. The whole point of this program would probably make no sense without reading the paper first. It’s only five pages, most of which are colorful pictures. You can also view a pdf of the code HERE.

This program runs in the terminal, so here’s a brief explanation of how to run it in case you don;t know how to already. The commands are the same in Linux Mac (Unix), or Windows. The first step is open your terminal of choice and navigate to where the file is using the command cd. (i.e. cd Desktop if the .java file is on your desktop):


Then type javac Timer.java to compile it as shown:


Then if it compiles, type java Timer as shown:


And then when you do that, the program will start up and ask you for a length of the dimension. I chose 10,000, which will produce a 10,000 by 10,000 2D array that we will use to examine properties of cache memory. The reasoning behind all this is explained in the paper, and the program doesn’t really make much sense without reading it. Anyway, after running it, you should see something like this:


Share on FacebookEmail this to someoneTweet about this on TwitterShare on Google+Share on LinkedInShare on Reddit