Performance Comparison of USB 2.0 vs. SATA II

Analysis of Non-Corresponding Measurements

 

Christopher L Griffis

Embry-Riddle Aeronautical University

 

Project Summary

 

Experimental Design

 

Analysis of Data

 

The Automation Software

 

The Spreadsheet

 

The Report

 

 

The Automation Software

 

The automation software was set up to provide a hands-free way of repeatedly transferring a file across the databus connection and recording the transfer time. It consists of three objects: FileTransferControl, FileTransferHandler, and RecordedDataHandler. FileTransferControl is responsible for coordinating the overall transfer process and recorded data export. It also contains the static main method, which calls its own class constructor. The constructor of FileTransferControl then gathers information via user prompts and initializes null references to the other objects (stored as class variables) by calling the respective class constructors of the other two objects. FileTransferHandler is responsible for managing the actual file transfer and storing the measured data in variables. The data in these variables are given to RecordedDataHandler, which then stores the measured data into a log file.

 

Figure 11 shows a UML diagram created in the design phase of the file transfer automation software development process. Following this is the source code for the three modules depicted in the UML diagram. It should be noted that because this software was for personal use, as a time saving strategy, it is not meant to be “foolproof” or “robust” code by any means.

 

Figure 11: UML Diagram of Transfer Automation Software

 

 


FileTransferControl

 

import javax.swing.*;

import java.awt.*;

import java.io.*;

import java.util.*;

 

public class FileTransferControl

{

                private RecordedDataHandler           rdh          = null;

                private FileTransferHandler               fth          = null;

 

                public FileTransferControl()

                {

                                int trialCount = 200;

                               

//                             trialCount = Integer.valueOf(JOptionPane.showInputDialog(null,"number of trials", "question", JOptionPane.QUESTION_MESSAGE));

                               

                                String str = ("there will be "+Integer.toString(trialCount)+" trials performed.");

                                JOptionPane.showMessageDialog(null,str, "attention", JOptionPane.INFORMATION_MESSAGE);

 

                                this.fth = new FileTransferHandler();

                                this.rdh = new RecordedDataHandler();

                               

                                while(trialCount>0)

                                {

                                                transfer();

                                                trialCount--;

                                }

                                this.rdh.closeFW();

                                System.exit(0);

                }

               

                private void transfer ()

                {

                                long t1=0,t2=0;

                               

                                t1=System.currentTimeMillis();

                                fth.copyFile();

                                t2=System.currentTimeMillis();

                               

                                long diff = t2-t1;

                                String str = "t1="+t1+"\nt2="+t2+"\ndiff="+diff+"\n";

                                System.out.println(str+"appending "+diff+"\n");

                                rdh.appendData(diff);

                }

 

                public static void main( String[] args )

                {

                                new FileTransferControl();

                }

}

 


FileTransferHandler

 

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import java.util.*;

import java.io.FileNotFoundException;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStreamReader;

 

public class FileTransferHandler

{

                //public static final int BUFFER_SIZE=1048576;

                //public static final int BUFFER_SIZE=4096;

               

                private int                                              BUFFER_SIZE = powbase2(15);

               

                private File                                            fromFile  = null;

                private File                                            toFile      = null;

                private FileInputStream                       from        = null;

                private FileOutputStream                    to            = null;

               

               

                public FileTransferHandler()

                {

 

//                             this.BUFFER_SIZE = powbase2(Integer.valueOf(JOptionPane.showInputDialog(null,"buffer size 10-20", "question", JOptionPane.QUESTION_MESSAGE)));

 

                                JOptionPane.showMessageDialog(null,("Buffer size is: "+BUFFER_SIZE), "attention", JOptionPane.INFORMATION_MESSAGE);

 

                                JOptionPane.showMessageDialog(null,"choose the source file", "attention", JOptionPane.INFORMATION_MESSAGE);

                                JFileChooser jfc1 = new JFileChooser("C:\\655\\source");

                                jfc1.showOpenDialog(null);

                                this.fromFile = jfc1.getSelectedFile();

                                JOptionPane.showMessageDialog(null,"source file chosen", "attention", JOptionPane.INFORMATION_MESSAGE);

                               

                                JOptionPane.showMessageDialog(null,"choose the target file", "attention", JOptionPane.INFORMATION_MESSAGE);

                                JFileChooser jfc2 = new JFileChooser("G:\\655\\target");

                                jfc2.showOpenDialog(null);

                                this.toFile = jfc2.getSelectedFile();

                                JOptionPane.showMessageDialog(null,"target file chosen", "attention", JOptionPane.INFORMATION_MESSAGE);

 

                }

 

                public void copyFile()

                {

                    try

                    {

                                                try

                                                {

                                                                System.out.print("copying...");

                                                                from = new FileInputStream(fromFile);

                                                                to = new FileOutputStream(toFile);

                                                                byte[] buffer = new byte[BUFFER_SIZE];

                                                                int bytesRead;

                                                               

                                                                while ((bytesRead = from.read(buffer)) != -1)

                                                                to.write(buffer, 0, bytesRead); // write

                                                }

                                                finally

                                                {

                                                  if (from != null)

                                                    try

                                                    {

                                                                from.close();

                                                    } catch (IOException e) {;}

                                                  if (to != null)

                                                    try

                                                    {

                                                      to.close();

                                                    } catch (IOException e) {;}

                                                }

                                                System.out.println("ok\n");

                   }

                    catch(FileNotFoundException fnf) {System.err.println("\nfth::fnf: "+fnf.getMessage()); }

                    catch(IOException ioe) {System.err.println("\nfth::ioe: "+ioe.getMessage());}

                    

                }

               

                private int powbase2(int exp)

                {

                                if(exp<1) return 1;

                                else return 2*powbase2(exp-1);

                }

 

}

 


RecordedDataHandler

 

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import java.io.*;

import java.util.*;

 

public class RecordedDataHandler

{

                private File                            dataFile = null;

                private FileWriter                 fw            = null;

 

                public RecordedDataHandler()

                {

                                try

                                {

                                                JOptionPane.showMessageDialog(null,"choose the file where the data gets recorded", "attention", JOptionPane.INFORMATION_MESSAGE);

                                                JFileChooser jfc = new JFileChooser("C:\\655\\data");

                                                jfc.showOpenDialog(null);

                                                this.dataFile = jfc.getSelectedFile();

                                                this.fw = new FileWriter(dataFile);

                                                JOptionPane.showMessageDialog(null,"data file chosen", "attention", JOptionPane.INFORMATION_MESSAGE);

                                } catch (IOException ioe) {;}

                }

 

                public void closeFW()

                {

                                try

                                {

                                                System.out.println("closing file writer");

                                                fw.close();

                                }

                                catch (IOException ioe) {System.err.println("\nrdh::ioe::fwclose: "+ioe.getMessage());};

                }

               

                public void appendData( long diff )

                {

                                try

                                {

                                                fw.append(Long.toString(diff));

                                                fw.append("\n");

                                } catch (IOException ioe) {System.err.println("\nrdh::ioe: "+ioe.getMessage());};

                }

}

  

Project Summary

 

Experimental Design

 

Analysis of Data

 

The Automation Software

 

The Spreadsheet

 

The Report