01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/test-harness/tags/sakai_2-4-1/src/java/org/sakaiproject/test/SakaiTestTimer.java $
03: * $Id: SakaiTestTimer.java 9715 2006-05-19 23:40:09Z jholtzman@berkeley.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Regents of the University of California
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.test;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24:
25: /**
26: *
27: * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
28: *
29: */
30: public class SakaiTestTimer {
31: private static final Log log = LogFactory
32: .getLog(SakaiTestTimer.class);
33: private String task;
34: private long start;
35:
36: /**
37: * Create a new SakaiTestTimer
38: *
39: * @param task
40: * The name of the task being timed
41: */
42: public SakaiTestTimer(String task) {
43: this .task = task;
44: restart();
45: }
46:
47: public void restart() {
48: start = System.currentTimeMillis();
49: }
50:
51: /**
52: * Log the elapsed time since this was created or reset.
53: */
54: public void logTimeElapsed() {
55: log.debug(task + ": " + (System.currentTimeMillis() - start)
56: + " ms");
57: }
58: }
|