Created
February 16, 2011 09:25
-
-
Save v6ak/829083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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