LockPerf benchmark
This commit is contained in:
@@ -1,20 +1,11 @@
|
|||||||
namespace lockperformance
|
namespace lockperformance
|
||||||
|
|
||||||
|
import std.concurrent.*
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
fun thread(f: fun ()) {
|
|
||||||
val thread = Thread(
|
|
||||||
object: Runnable {
|
|
||||||
override fun run() {
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
thread.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> Int.latch(op: fun CountDownLatch.() : T) : T {
|
fun <T> Int.latch(op: fun CountDownLatch.() : T) : T {
|
||||||
val cdl = CountDownLatch(this)
|
val cdl = CountDownLatch(this)
|
||||||
val res = cdl.op()
|
val res = cdl.op()
|
||||||
@@ -22,7 +13,7 @@ fun <T> Int.latch(op: fun CountDownLatch.() : T) : T {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Int.times(action: fun Int.()) {
|
fun Int.times(action: fun():Unit) {
|
||||||
for(i in 0..this-1)
|
for(i in 0..this-1)
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user