Java Doc for StopWatch.java in  » Library » Apache-common-lang » org » apache » commons » lang » time » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common lang » org.apache.commons.lang.time 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.lang.time.StopWatch

StopWatch
public class StopWatch (Code)

StopWatch provides a convenient API for timings.

To start the watch, call StopWatch.start() . At this point you can:

  • StopWatch.split() the watch to get the time whilst the watch continues in the background. StopWatch.unsplit() will remove the effect of the split. At this point, these three options are available again.
  • StopWatch.suspend() the watch to pause it. StopWatch.resume() allows the watch to continue. Any time between the suspend and resume will not be counted in the total. At this point, these three options are available again.
  • StopWatch.stop() the watch to complete the timing session.

It is intended that the output methods StopWatch.toString() and StopWatch.getTime() should only be called after stop, split or suspend, however a suitable result will be returned at other points.

NOTE: As from v2.1, the methods protect against inappropriate calls. Thus you cannot now call stop before start, resume before suspend or unsplit before split.

1. split(), suspend(), or stop() cannot be invoked twice
2. unsplit() may only be called if the watch has been split()
3. resume() may only be called if the watch has been suspend()
4. start() cannot be called twice without calling reset()


author:
   Stephen Colebourne
since:
   2.0
version:
   $Id: StopWatch.java 504351 2007-02-06 22:49:50Z bayard $



Constructor Summary
public  StopWatch()
    

Method Summary
public  longgetSplitTime()
    

Get the split time on the stopwatch.

This is the time between start and latest split.

public  longgetTime()
    
public  voidreset()
    

Resets the stopwatch.

public  voidresume()
    

Resume the stopwatch after a suspend.

This method resumes the watch after it was suspended.

public  voidsplit()
    

Split the time.

This method sets the stop time of the watch to allow a time to be extracted.

public  voidstart()
    
public  voidstop()
    
public  voidsuspend()
    

Suspend the stopwatch for later resumption.

This method suspends the watch until it is resumed.

public  StringtoSplitString()
    
public  StringtoString()
    
public  voidunsplit()
    

Remove a split.

This method clears the stop time.



Constructor Detail
StopWatch
public StopWatch()(Code)

Constructor.





Method Detail
getSplitTime
public long getSplitTime()(Code)

Get the split time on the stopwatch.

This is the time between start and latest split.

the split time in milliseconds
throws:
  IllegalStateException - if the StopWatch has not yet been split.
since:
   2.1



getTime
public long getTime()(Code)

Get the time on the stopwatch.

This is either the time between the start and the moment this method is called, or the amount of time between start and stop.

the time in milliseconds



reset
public void reset()(Code)

Resets the stopwatch. Stops it if need be.

This method clears the internal values to allow the object to be reused.




resume
public void resume()(Code)

Resume the stopwatch after a suspend.

This method resumes the watch after it was suspended. The watch will not include time between the suspend and resume calls in the total time.


throws:
  IllegalStateException - if the StopWatch has not been suspended.



split
public void split()(Code)

Split the time.

This method sets the stop time of the watch to allow a time to be extracted. The start time is unaffected, enabling StopWatch.unsplit() to continue the timing from the original start point.


throws:
  IllegalStateException - if the StopWatch is not running.



start
public void start()(Code)

Start the stopwatch.

This method starts a new timing session, clearing any previous values.


throws:
  IllegalStateException - if the StopWatch is already running.



stop
public void stop()(Code)

Stop the stopwatch.

This method ends a new timing session, allowing the time to be retrieved.


throws:
  IllegalStateException - if the StopWatch is not running.



suspend
public void suspend()(Code)

Suspend the stopwatch for later resumption.

This method suspends the watch until it is resumed. The watch will not include time between the suspend and resume calls in the total time.


throws:
  IllegalStateException - if the StopWatch is not currently running.



toSplitString
public String toSplitString()(Code)

Gets a summary of the split time that the stopwatch recorded as a string.

The format used is ISO8601-like, hours:minutes:seconds.milliseconds.

the split time as a String
since:
   2.1



toString
public String toString()(Code)

Gets a summary of the time that the stopwatch recorded as a string.

The format used is ISO8601-like, hours:minutes:seconds.milliseconds.

the time as a String



unsplit
public void unsplit()(Code)

Remove a split.

This method clears the stop time. The start time is unaffected, enabling timing from the original start point to continue.


throws:
  IllegalStateException - if the StopWatch has not been split.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.