类 StopwatchCPU
- java.lang.Object
-
- edu.princeton.cs.algs4.StopwatchCPU
-
public class StopwatchCPU extends java.lang.Object
TheStopwatchCPU
data type is for measuring the CPU time used during a programming task. SeeStopwatch
for a version that measures wall-clock time (the real time that elapses).
-
-
构造器概要
构造器 构造器 说明 StopwatchCPU()
Initializes a new stopwatch.
-
方法概要
修饰符和类型 方法 说明 double
elapsedTime()
Returns the elapsed CPU time (in seconds) since the stopwatch was created.static void
main(java.lang.String[] args)
Unit tests theStopwatchCPU
data 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 theStopwatchCPU
data type. Takes a command-line argumentn
and computes the sum of the square roots of the firstn
positive 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
-
-