/*
 * All software distributed from this site Copyright The Regents of the
 * University of California and the UCSD Software Evolution Group.  All
 * Rights Reserved.
 * 
 * Permission to use, copy, modify, and distribute any part of the software
 * from this site for educational, research, and non-profit purposes,
 * without fee and without a written agreement, is hereby granted, provided
 * that the above copyright notice, this paragraph and the the following
 * three paragraphs appear in all copies.
 * 
 * For permission to use software from this site for commercial purposes,
 * contact * William G. Griswold (wgg@cs.ucsd.edu), the software's author,
 * or send U.S. Mail to:
 * 
 *         William G. Griswold
 *         Department of Computer Science and Engineering, 0114
 *         University of California, San Diego
 *         La Jolla, CA 92093-0114
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF SOFTWARE FROM THIS SITE, EVEN IF THE UNIVERSITY OF CALIFORNIA
 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE
 * UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
 * SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.  THE UNIVERSITY OF
 * CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND,
 * EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT
 * THE USE OF THE MATERIAL WILL NOT INFRINGE ANY PATENT, TRADEMARK OR OTHER
 * RIGHTS.
 */

import java.io.*;

public class Timer {
	private long base_time;
	private long elapsed_time;

	private static final long UNIT = 1000;

	public Timer() {
		clear();
	}

	public void mark() {
		base_time = System.currentTimeMillis();
	}

	public void clear() {
		elapsed_time = 0;
	}

	public void record() {
		elapsed_time += (System.currentTimeMillis() - base_time);
	}

	public float elapsed() {
		return ((float) elapsed_time) / UNIT;
	}

	public void report(PrintStream pstream) {
		float elapsed_seconds = elapsed();
		pstream.println("Time " + elapsed_seconds + " sec");
	}
	public void report() {
		report(System.out);
	}

}

