Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created February 16, 2011 09:25
Show Gist options
  • Select an option

  • Save v6ak/829083 to your computer and use it in GitHub Desktop.

Select an option

Save v6ak/829083 to your computer and use it in GitHub Desktop.
def timeBench(t: =>Unit, count: Int){
val t1 = System.currentTimeMillis
try{
(1 to count).foreach{x =>
t/*()*/
}
}finally{
val t2 = System.currentTimeMillis
val timeSec = (t2-t1)/1000.0;
println("\ntotal time:\t" + timeSec + "s");
println("avg time:\t" + timeSec/count + "s");
}
}
def time(t: =>Unit){
timeBench(t, 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment