I'm trying to measure the response time for a "process" (I'm requesting data from a server and then presenting the data). I want to measure the time it takes from when I ask for the data (when I press the "send" button) to when the data is displayed in my txtbox.
That looks like this:
    (these two are at the very top:)
    private long a
    private long b
   ...other code...
    a = System.currentTimeMillis();
    btnSend.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String fileContents;
            b = System.currentTimeMillis();
            try {
                fileContents = control.getFileContents(txtSearch.getText());
                txtView.setText(fileContents + "\n" + "\n" + "The process took "+(b-a)+"milliseconds to execute." + "\n" + "("+((b-a)/1000)+" seconds)");
            } catch (RemoteException e) {
                txtView.setText("File not found");
            }
        }
Ant it works, but just the first time. If I send another request the time is just added to the old time. The first request takes 2 seconds, and the second it says it took 7 seconds (when in reality it took like 2).
I tried circumventing the problem by reseting a and b by putting:
    a = 0; 
    b = 0;
in the reset button, but that only seem to have made things go a bit crazy.
Any thoughts on how to solve the problem?
Thanks
 
    