blob: 0fe96251977e2eadd2a6f026bf19907028c73145 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.tools.util
import compat.Platform.currentTime
import scala.collection.mutable.Stack
/**
* This abstract class implements the collection of timings. How the
* collected timings are issued has to be implemented in subclasses.
*
* @author Philippe Altherr
* @version 1.0
*/
abstract class AbstractTimer {
//########################################################################
// Private Fields
/** A stack for maintaining start times */
private val starts = new Stack[Long]()
//########################################################################
// Public Methods
/** Issues a timing information (duration in milliseconds). */
def issue(message: String, duration: Long): Unit
/** Starts a new timer. */
def start() {
starts += currentTime
}
/** Ends the current timer. */
def stop(message: String) {
val stop = currentTime
issue(message, stop - starts.pop)
}
/** Drops the current timer. */
def drop() {
starts.pop
}
//########################################################################
}
|