01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.util;
06:
07: /**
08: * A bean that can be used to time execution of pages
09: *
10: * @author Rickard Öberg (rickard@middleware-company.com)
11: * @version $Revision: 1282 $
12: */
13: public class Timer {
14:
15: // Attributes ----------------------------------------------------
16: long current = System.currentTimeMillis();
17: long start = current;
18:
19: // Public --------------------------------------------------------
20: public long getTime() {
21: // Return how long time has passed since last check point
22: long now = System.currentTimeMillis();
23: long time = now - current;
24:
25: // Reset so that next time we get from this point
26: current = now;
27:
28: return time;
29: }
30:
31: public long getTotal() {
32: // Reset start so that next time we get from this point
33: return System.currentTimeMillis() - start;
34: }
35: }
|