FileDocCategorySizeDatePackage
IOTest.javaAPI DocExample14566Wed Apr 05 23:01:48 BST 2000tuning.io

IOTest

public class IOTest extends Object

Fields Summary
static int
nlines
static int
tchars
public static final char[]
MAP3
Constructors Summary
public IOTest()

    
Methods Summary
public static voidbuffered8192InputStream(java.lang.String s)

        DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(s), 8192));
        long l = System.currentTimeMillis();
        String s1;
        while((s1 = datainputstream.readLine()) != null) 
            doSomethingWith(s1);

        l = System.currentTimeMillis() - l;
        datainputstream.close();
        System.out.println("Time for reading " + nlines + " lines (chars " + tchars + ") using buffered8KInputStream: " + l);
    
public static voidbufferedInputStream(java.lang.String s)

        DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(s)));
        long l = System.currentTimeMillis();
        String s1;
        while((s1 = datainputstream.readLine()) != null) 
            doSomethingWith(s1);

        l = System.currentTimeMillis() - l;
        datainputstream.close();
        System.out.println("Time for reading " + nlines + " lines (chars " + tchars + ") using bufferedInputStream  : " + l);
    
public static voidbufferedReader(java.lang.String s)

        BufferedReader bufferedreader = new BufferedReader(new FileReader(s));
        long l = System.currentTimeMillis();
        String s1;
        while((s1 = bufferedreader.readLine()) != null) 
            doSomethingWith(s1);

        l = System.currentTimeMillis() - l;
        bufferedreader.close();
        System.out.println("Time for reading " + nlines + " lines (chars " + tchars + ") using bufferedReader       : " + l);
    
public static intconvert(byte[] abyte0, int i, int j, char[] ac, int k, int l, char[] ac1)

        int i1 = j;
        boolean flag = false;
        if(j - i > l - k)
        {
            i1 = i + (l - k);
            flag = true;
        }
        int j1 = k;
        if(i1 - i > 10)
        {
            i1 -= 10;
            int k1;
            for(k1 = i; k1 < i1;)
            {
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
                ac[j1++] = ac1[abyte0[k1++] + 128];
            }

            for(i1 += 10; k1 < i1;)
                ac[j1++] = ac1[abyte0[k1++] + 128];

        }
        else
        {
            for(int l1 = i; l1 < i1;)
                ac[j1++] = ac1[abyte0[l1++] + 128];

        }
        if(flag)
            throw new Exception();
        else
            return j1 - k;
    
public static voiddoSomethingWith(char[] ac, int i, int j)

        nlines++;
        tchars += (j - i) + 1;
    
public static voiddoSomethingWith(java.lang.String s)

        nlines++;
        tchars += s.length();
    
public static voidmain(java.lang.String[] args)


        
    
//        System.out.println(System.getProperties());
        try
        {
            unbufferedInputStream(args[0]);
            reset();
            bufferedInputStream(args[0]);
            reset();
            buffered8192InputStream(args[0]);
            reset();
            bufferedReader(args[0]);
            reset();
            myReader(args[0]);
            reset();
            myReader2(args[0]);
            reset();
            unbufferedInputStream(args[0]);
            reset();
            bufferedInputStream(args[0]);
            reset();
            buffered8192InputStream(args[0]);
            reset();
            bufferedReader(args[0]);
            reset();
            myReader(args[0]);
            reset();
            myReader2(args[0]);
            reset();
            return;
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    
public static voidmyReader(java.lang.String string)

    //Do the processing myself, directly from a FileReader
    //But don