All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.princeton.cs.introcs.Stopwatch Maven / Gradle / Ivy

Go to download

Standard input and output libraries from Princeton's "Introduction to Programming in Java" textbook.

The newest version!
package edu.princeton.cs.introcs;

/*************************************************************************
 *  Compilation:  javac Stopwatch.java
 *
 *
 *************************************************************************/

/**
 *  Stopwatch. This class is a data type for measuring
 *  the running time (wall clock) of a program.
 *  

* For additional documentation, see * Section 3.2 of * Introduction to Programming in Java: An Interdisciplinary Approach * by Robert Sedgewick and Kevin Wayne. */ public class Stopwatch { private final long start; /** * Create a stopwatch object. */ public Stopwatch() { start = System.currentTimeMillis(); } /** * Return elapsed time (in seconds) since this object was created. */ public double elapsedTime() { long now = System.currentTimeMillis(); return (now - start) / 1000.0; } } /************************************************************************* * Copyright 2002-2012, Robert Sedgewick and Kevin Wayne. * * This file is part of stdlib-package.jar, which accompanies the textbook * * Introduction to Programming in Java: An Interdisciplinary Approach * by R. Sedgewick and K. Wayne, Addison-Wesley, 2007. ISBN 0-321-49805-4. * * http://introcs.cs.princeton.edu * * * stdlib-package.jar is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * stdlib-package.jar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with stdlib-package.jar. If not, see http://www.gnu.org/licenses. *************************************************************************/





© 2015 - 2024 Weber Informatics LLC | Privacy Policy