Skip to content
Snippets Groups Projects
Commit cf165fd4 authored by Christian Wulf's avatar Christian Wulf
Browse files

completed migration

parent b7dc8162
No related branches found
No related tags found
No related merge requests found
package teetime.util.concurrent.workstealing.alternative;
import org.hamcrest.number.OrderingComparison;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import teetime.util.StopWatch;
public class CircularWorkStealingDequeWithSentinelTest {
private StopWatch stopWatch;
@Before
public void before() {
this.stopWatch = new StopWatch();
}
@Test
public void measureManyEmptyPulls() {
final CircularWorkStealingDequeWithSentinel<Object> deque = new CircularWorkStealingDequeWithSentinel<Object>();
final int numIterations = UntypedCircularWorkStealingDequeTest.NUM_ITERATIONS;
this.stopWatch.start();
for (int i = 0; i < numIterations; i++) {
deque.popBottom();
// if (returnValue.getState() != State.EMPTY) {
// returnValue.getValue();
// }
}
this.stopWatch.end();
Assert.assertThat(this.stopWatch.getDuration(), OrderingComparison.lessThan(UntypedCircularWorkStealingDequeTest.EXPECTED_DURATION));
}
}
package teetime.util.concurrent.workstealing.alternative;
import org.hamcrest.number.OrderingComparison;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import teetime.util.StopWatch;
public class CircularWorkStealingDequeWithThreadLocalSentinelTest {
private StopWatch stopWatch;
@Before
public void before() {
this.stopWatch = new StopWatch();
}
@Test
public void measureManyEmptyPulls() {
final CircularWorkStealingDequeWithThreadLocalSentinel<Object> deque = new CircularWorkStealingDequeWithThreadLocalSentinel<Object>();
final int numIterations = UntypedCircularWorkStealingDequeTest.NUM_ITERATIONS;
this.stopWatch.start();
for (int i = 0; i < numIterations; i++) {
deque.popBottom();
// if (returnValue.getState() != State.EMPTY) {
// returnValue.getValue();
// }
}
this.stopWatch.end();
Assert.assertThat(this.stopWatch.getDuration(), OrderingComparison.lessThan(UntypedCircularWorkStealingDequeTest.EXPECTED_DURATION));
}
}
package teetime.util.concurrent.workstealing.alternative;
import org.hamcrest.number.OrderingComparison;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import teetime.util.StopWatch;
import teetime.util.concurrent.workstealing.exception.DequeIsEmptyException;
@Ignore
public class ExceptionalCircularWorkStealingDequeTest {
private StopWatch stopWatch;
@Before
public void before() {
this.stopWatch = new StopWatch();
}
@Test
public void measureManyEmptyPulls() {
final ExceptionalCircularWorkStealingDeque<String> deque = new ExceptionalCircularWorkStealingDeque<String>();
final int numIterations = UntypedCircularWorkStealingDequeTest.NUM_ITERATIONS;
this.stopWatch.start();
for (int i = 0; i < numIterations; i++) {
try {
deque.popBottom();
} catch (final DequeIsEmptyException e) {
// do not handle; we just want to compare the performance of throwing a preallocated exception vs. returning special values
}
}
this.stopWatch.end();
Assert.assertThat(this.stopWatch.getDuration(), OrderingComparison.lessThan(UntypedCircularWorkStealingDequeTest.EXPECTED_DURATION));
}
}
package teetime.util.concurrent.workstealing.alternative;
import org.hamcrest.number.OrderingComparison;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import teetime.util.StopWatch;
public class UntypedCircularWorkStealingDequeTest {
public static final int NUM_ITERATIONS = 100000000;
public static final long EXPECTED_DURATION = 1100;
private StopWatch stopWatch;
@Before
public void before() {
this.stopWatch = new StopWatch();
}
@Test
public void measureManyEmptyPulls() {
final UntypedCircularWorkStealingDeque deque = new UntypedCircularWorkStealingDeque();
final int numIterations = NUM_ITERATIONS;
this.stopWatch.start();
for (int i = 0; i < numIterations; i++) {
deque.popBottom();
}
this.stopWatch.end();
Assert.assertThat(this.stopWatch.getDuration(), OrderingComparison.lessThan(UntypedCircularWorkStealingDequeTest.EXPECTED_DURATION));
}
}
package teetime.util.concurrent.workstealing.alternative;
import org.hamcrest.number.OrderingComparison;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import teetime.util.StopWatch;
import teetime.util.concurrent.workstealing.exception.DequeIsEmptyException;
public class UntypedExceptionalCircularWorkStealingDequeTest {
private StopWatch stopWatch;
@Before
public void before() {
this.stopWatch = new StopWatch();
}
@Test
public void measureManyEmptyPulls() {
final UntypedExceptionalCircularWorkStealingDeque deque = new UntypedExceptionalCircularWorkStealingDeque();
System.out.println(UntypedExceptionalCircularWorkStealingDeque.DEQUE_IS_EMPTY_EXCEPTION);
System.out.println(UntypedExceptionalCircularWorkStealingDeque.OPERATION_ABORTED_EXCEPTION);
int counter = 0;
final int numIterations = UntypedCircularWorkStealingDequeTest.NUM_ITERATIONS;
this.stopWatch.start();
for (int i = 0; i < numIterations; i++) {
try {
deque.popBottom();
} catch (final DequeIsEmptyException e) {
// do not handle; we just want to compare the performance of throwing a preallocated exception vs. returning special values
counter++;
}
}
this.stopWatch.end();
Assert.assertThat(this.stopWatch.getDuration(), OrderingComparison.lessThan(UntypedCircularWorkStealingDequeTest.EXPECTED_DURATION));
Assert.assertThat(counter, OrderingComparison.comparesEqualTo(UntypedCircularWorkStealingDequeTest.NUM_ITERATIONS));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment