mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 11:02:25 +00:00
added locking performance test
This commit is contained in:
1 parent
cdbf910502
commit
a551869059
1 file changed
+14
@@ -6,6 +6,7 @@ import java.util.concurrent.locks.Lock;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.util.impl.LockUtil;
|
||||
import com.sap.sailing.util.impl.NamedReentrantReadWriteLock;
|
||||
|
||||
public class LockTraceTest {
|
||||
@@ -34,6 +35,19 @@ public class LockTraceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockingPerformance() {
|
||||
NamedReentrantReadWriteLock lock = new NamedReentrantReadWriteLock("Lock", /* fair */ true);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i=0; i<100000; i++) {
|
||||
LockUtil.lockForRead(lock);
|
||||
LockUtil.unlockAfterRead(lock);
|
||||
LockUtil.lockForWrite(lock);
|
||||
LockUtil.unlockAfterWrite(lock);
|
||||
}
|
||||
System.out.println("Took "+(System.currentTimeMillis()-start)+"ms");
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testLockTraceForMultipleReaders() throws InterruptedException {
|
||||
|
||||
Reference in new issue
Block a user