4.6 Testing file latency

In this exercise, we will be writing a simple Java test program to discover the relative performance hit from using SMB4.1 or NFS against using the local file system.

Performance testing is a difficult area in which to work, since to get accurate figures many factors need to be taken into account.

However, as a system designer, you will need back of the envelope magnitudes with which to calculate the approximate performance and where the likely bottlenecks will be. So some rough and ready performance measurement will need to be part of your arsenal.

In this exercise you will write a Java program which creates a configurable number of files filled with a configurable amount of random data in a specified directory. Time how long it takes to create the files the directory. Compare your answers across SMB or NFS mounted file stores and local file stores, and between buffered writers and non-buffered writers. Plot graphs of time taken against normalized file size if you have time - tools such as gnuplot are useful here.

Fill out the following template so that the user can create a number of test files filled out with data. The following classes are necessary:

import java.io.*;

class Filetest {
    static final String TESTPREFIX = "ds";    
    static final String TESTSUFFIX = "test";

    public static long runTest(File dir, int num, int size) throws IOException 
    {
        // Create our data
        // Create the arrays of files and outputstreams
        // populate the array of files with open files
        // Time how long it takes...
        // To go through the array of files...
        // Calculate the time
        // Delete the files
        // return the time taken
    }

    
    public static void main(String[] args) {
        try {
            if(args.length > 0) {
                 int size = Integer.parseInt(args[0]);
                 int num = Integer.parseInt(args[1]);
                 File dir = new File(args[2]);
                 System.out.println(num + " files of " +
                                    size + " Kbyte in " + args[2] + 
                                    " took " +
                                    Filetest.runTest(dir,num,size) + "ms");
             } else {
                 System.out.println("Usage: java Filetest size num dir");
             }
            
        } catch (IOException ioe) {
            System.err.print(ioe.getMessage());
            System.err.print(ioe);
        }
    }
    
}

My version of Filetest.java.

Ian Wakeman 2005-02-22