本文整理汇总了Scala中java.lang.System.currentTimeMillis类的典型用法代码示例。如果您正苦于以下问题:Scala currentTimeMillis类的具体用法?Scala currentTimeMillis怎么用?Scala currentTimeMillis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了currentTimeMillis类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: time
//设置package包名称以及导入依赖的类
package org.hammerlab.timing
import java.lang.System.currentTimeMillis
import grizzled.slf4j.Logging
trait Timer {
self: Logging ?
def time[T](fn: ? T): T = time("")(fn)
def time[T](msg: ? String)(fn: ? T): T = {
val before = currentTimeMillis
val res = fn
val after = currentTimeMillis
info(s"$msg:\t${after-before}ms")
res
}
}
示例2: InMemoryIOMonitor
//设置package包名称以及导入依赖的类
package michid.script.oak.filestore
import java.io.File
import java.lang.System.currentTimeMillis
import java.util.UUID
import ammonite.ops.Path
import org.apache.jackrabbit.oak.segment.file.IOMonitorAdapter
import scala.collection.concurrent.{Map, TrieMap}
import scala.collection.mutable.ListBuffer
class InMemoryIOMonitor extends IOMonitorAdapter {
val reads: Map[(Long, Long), SegmentAccess] = TrieMap()
override def beforeSegmentRead(file: File, msb: Long, lsb: Long, length: Int): Unit = {
reads.getOrElseUpdate((msb, lsb), SegmentAccess(Path(file), msb, lsb))
.accessed(currentTimeMillis())
}
}
case class SegmentAccess(path: Path, lsb: Long, msb: Long) {
val timeStamps: ListBuffer[Long] = ListBuffer.empty
def accessed(ts: Long): Unit = this.synchronized {
timeStamps += ts
}
override def toString: String =
s"${new UUID(msb, lsb)} @ ${path.name}: ${timeStamps.mkString(",")}"
}
object InMemoryIOMonitor {
def apply() = new InMemoryIOMonitor
}