You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
718 B

package com.sothr.imagetools.hash.util
import grizzled.slf4j.Logging
trait TimingUtil extends Logging {
def time[R](block: => R): R = {
val t0 = System.currentTimeMillis
val result = block // call-by-name
val t1 = System.currentTimeMillis
debug("Elapsed time: " + (t1 - t0) + "ms")
result
}
def getTime[R](block: => R): Long = {
val t0 = System.currentTimeMillis
val result = block // call-by-name
val t1 = System.currentTimeMillis
debug("Elapsed time: " + (t1 - t0) + "ms")
t1 - t0
}
def getMean(times: Long*): Long = {
getMean(times.toArray[Long])
}
def getMean(times: Array[Long]): Long = {
var ag = 0L
for (i <- times.indices) {
ag += times(i)
}
ag / times.length
}
}