Skip to content
Snippets Groups Projects
Commit 19fc9838 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Remove unused files

parent c8eb81d6
No related branches found
No related tags found
No related merge requests found
/* Copyright 2009-2015 EPFL, Lausanne */
package leon
class StopwatchCollection(name: String) {
var acc: Long = 0L
var stopwatches = List[Stopwatch]()
def +=(sw: Stopwatch) = synchronized { acc += sw.getMillis }
def getMillis = {
val running =
(0L /: stopwatches) {
(res, sw) => res + sw.getMillis
}
acc + running
}
def newStopwatch = {
val result = new Stopwatch()
stopwatches :+= result
result
}
override def toString = f"$name%20s: ${acc}%5dms"
}
/** Implements a stopwatch for profiling purposes */
class Stopwatch(name: String = "Stopwatch") {
var beginning: Long = 0L
var end: Long = 0L
var acc: Long = 0L
def start: this.type = {
beginning = System.currentTimeMillis
end = 0L
this
}
def stop() {
end = System.currentTimeMillis
acc += (end - beginning)
beginning = 0L
}
def getMillis: Long = {
if (isRunning) {
acc + (System.currentTimeMillis-beginning)
} else {
acc
}
}
def profile[T](block: => T): T = {
if (isRunning) stop()
start
val result = block // call-by-name
stop()
result
}
def isRunning = beginning != 0L
override def toString = f"$name%20s: $getMillis%5d${if (isRunning) "..." else ""}ms"
}
object StopwatchCollections {
private var all = Map[String, StopwatchCollection]()
def get(name: String): StopwatchCollection = all.getOrElse(name, {
val sw = new StopwatchCollection(name)
all += name -> sw
sw
})
def getAll = all
}
/* Copyright 2009-2015 EPFL, Lausanne */
package leon.utils
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment