abstracttimer.scala

来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 55 行

SCALA
55
字号
/*                     __                                               *\**     ________ ___   / /  ___     Scala API                            ****    / __/ __// _ | / /  / _ |    (c) 2002-2007, LAMP/EPFL             ****  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **** /____/\___/_/ |_/____/_/ | |                                         ****                          |/                                          **\*                                                                      */// $Id: AbstractTimer.scala 11100 2007-05-21 08:32:16Z michelou $package scala.tools.utilimport compat.Platform.currentTimeimport 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  }    //########################################################################}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?