类 Stopwatch
- java.lang.Object
-
- edu.princeton.cs.algs4.Stopwatch
-
public class Stopwatch extends java.lang.ObjectTheStopwatchdata type is for measuring the time that elapses between the start and end of a programming task (wall-clock time). SeeStopwatchCPUfor a version that measures CPU time. For additional documentation, see Section 1.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
-
-
构造器概要
构造器 构造器 说明 Stopwatch()Initializes a new stopwatch.
-
方法概要
修饰符和类型 方法 说明 doubleelapsedTime()Returns the elapsed CPU time (in seconds) since the stopwatch was created.static voidmain(java.lang.String[] args)Unit tests theStopwatchdata type.
-
-
-
方法详细资料
-
elapsedTime
public double elapsedTime()
Returns the elapsed CPU time (in seconds) since the stopwatch was created.- 返回:
- elapsed CPU time (in seconds) since the stopwatch was created
-
main
public static void main(java.lang.String[] args)
Unit tests theStopwatchdata type. Takes a command-line argumentnand computes the sum of the square roots of the firstnpositive integers, first usingMath.sqrt(), then usingMath.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).- 参数:
args- the command-line arguments
-
-