forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue ReactiveX#30 Switch from jacoco to cobertura
* test coverage added + jacoco excludes for benchmark classes * Issue#15 circular fifo bufer optimization (ReactiveX#29) * Issue#15 New optimized implementation of CircularFifoBuffer * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Move all test reporting to cobertura * Time alignment for decorator test * Additional tests and time alignment in spin loop
- Loading branch information
1 parent
73d7f75
commit 17b2197
Showing
15 changed files
with
573 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/jmh/java/io/github/robwin/circularbuffer/CircularBufferBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* | ||
* Copyright 2016 Robert Winkler and Bohdan Storozhuk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* | ||
*/ | ||
package io.github.robwin.circularbuffer; | ||
|
||
|
||
import javaslang.collection.List; | ||
import javaslang.control.Option; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Group; | ||
import org.openjdk.jmh.annotations.GroupThreads; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* @author bstorozhuk | ||
*/ | ||
@State(Scope.Benchmark) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@BenchmarkMode(Mode.AverageTime) | ||
public class CircularBufferBenchmark { | ||
public static final int FORK_COUNT = 2; | ||
private static final int WARMUP_COUNT = 10; | ||
private static final int ITERATION_COUNT = 10; | ||
private static final int CAPACITY = 10; | ||
private CircularFifoBuffer<Object> circularFifoBuffer; | ||
private Object event; | ||
|
||
@Setup | ||
public void setUp() { | ||
event = new Object(); | ||
circularFifoBuffer = new ConcurrentCircularFifoBuffer<>(CAPACITY); | ||
} | ||
|
||
@Benchmark | ||
@Warmup(iterations = WARMUP_COUNT) | ||
@Fork(value = FORK_COUNT) | ||
@Measurement(iterations = ITERATION_COUNT) | ||
@Group("circularBuffer") | ||
@GroupThreads(1) | ||
public void circularBufferAddEvent() { | ||
circularFifoBuffer.add(event); | ||
} | ||
|
||
@Benchmark | ||
@Warmup(iterations = WARMUP_COUNT) | ||
@Fork(value = FORK_COUNT) | ||
@Measurement(iterations = ITERATION_COUNT) | ||
@Group("circularBuffer") | ||
@GroupThreads(1) | ||
public void circularBufferToList(Blackhole bh) { | ||
List<Object> events = circularFifoBuffer.toList(); | ||
bh.consume(events); | ||
} | ||
|
||
@Benchmark | ||
@Warmup(iterations = WARMUP_COUNT) | ||
@Fork(value = FORK_COUNT) | ||
@Measurement(iterations = ITERATION_COUNT) | ||
@Group("circularBuffer") | ||
@GroupThreads(1) | ||
public void circularBufferSize(Blackhole bh) { | ||
int size = circularFifoBuffer.size(); | ||
bh.consume(size); | ||
} | ||
|
||
@Benchmark | ||
@Warmup(iterations = WARMUP_COUNT) | ||
@Fork(value = FORK_COUNT) | ||
@Measurement(iterations = ITERATION_COUNT) | ||
@Group("circularBuffer") | ||
@GroupThreads(1) | ||
public void circularBufferTakeEvent(Blackhole bh) { | ||
Option<Object> event = circularFifoBuffer.take(); | ||
bh.consume(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.