TimeWatch

package com.liuxt.sort;

import java.util.Calendar;

public class TimeWatch {

 long start_time;

 long stop_time;

 public TimeWatch() {

 }

 public void start() {
  start_time = Calendar.getInstance().getTimeInMillis();
 }

 public void stop() {
  stop_time = Calendar.getInstance().getTimeInMillis();
 }

 public long getTimeInMillis() {
  return this.stop_time - this.start_time;
 }

 public void showElapsedTime() {
  System.out.printf("elapsed time: %d ms\n", this.getTimeInMillis());

 }

}

你可能感兴趣的:(java)