System.timeMillis method renamed to measureTimeMillis and measureTimeNano added

This commit is contained in:
Alex Tkachman
2011-12-20 12:54:21 +02:00
parent 0134276930
commit 117f03cbbf
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ fun main(args: Array<String>) {
while(threadNum <= 1024) { while(threadNum <= 1024) {
val counter = AtomicInteger() val counter = AtomicInteger()
val duration = millisTime { val duration = measureTimeMillis {
threadNum.latch{ threadNum.latch{
val lock = ReentrantLock() val lock = ReentrantLock()
for(i in 0..threadNum-1) { for(i in 0..threadNum-1) {
+10 -1
View File
@@ -3,8 +3,17 @@ namespace std.util
/** /**
Executes current block and returns elapsed time in milliseconds Executes current block and returns elapsed time in milliseconds
*/ */
fun millisTime(block: fun() : Unit) : Long { fun measureTimeMillis(block: fun() : Unit) : Long {
val start = System.currentTimeMillis() val start = System.currentTimeMillis()
block() block()
return System.currentTimeMillis() - start return System.currentTimeMillis() - start
}
/**
Executes current block and returns elapsed time in milliseconds
*/
fun measureTimeNano(block: fun() : Unit) : Long {
val start = System.nanoTime()
block()
return System.nanoTime() - start
} }