System.timeMillis method renamed to measureTimeMillis and measureTimeNano added
This commit is contained in:
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user