Documentation of 'edu.princeton.cs.algs4.StopwatchCPU' Java class
StopwatchCPU
edu.princeton.cs.algs4

Class StopwatchCPU



  • public class StopwatchCPU
    extends java.lang.Object
    The StopwatchCPU data type is for measuring the CPU time used during a programming task. See Stopwatch for a version that measures wall-clock time (the real time that elapses).
    • Constructor Summary

      Constructors 
      Constructor and Description
      StopwatchCPU()
      Initializes a new stopwatch.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double elapsedTime()
      Returns the elapsed CPU time (in seconds) since the stopwatch was created.
      static void main(java.lang.String[] args)
      Unit tests the StopwatchCPU data type.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StopwatchCPU

        public StopwatchCPU()
        Initializes a new stopwatch.
    • Method Detail

      • elapsedTime

        public double elapsedTime()
        Returns the elapsed CPU time (in seconds) since the stopwatch was created.
        Returns:
        elapsed CPU time (in seconds) since the stopwatch was created
      • main

        public static void main(java.lang.String[] args)
        Unit tests the StopwatchCPU data type. Takes a command-line argument n and computes the sum of the square roots of the first n positive integers, first using Math.sqrt(), then using Math.pow(). It prints to standard output the sum and the amount of time to compute the sum. Note that the discrete sum can be approximated by an integral - the sum should be approximately 2/3 * (n^(3/2) - 1).
        Parameters:
        args - the command-line arguments

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.