-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1350 from benjchristensen/perf-tests
Baseline Performance Tests
- Loading branch information
Showing
4 changed files
with
94 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package rx.usecases; | ||
|
||
import java.util.Iterator; | ||
|
||
import org.openjdk.jmh.annotations.GenerateMicroBenchmark; | ||
|
||
public class PerfBaseline { | ||
|
||
@GenerateMicroBenchmark | ||
public void forLoopConsumption(UseCaseInput input) throws InterruptedException { | ||
for (int i = 0; i < input.size; i++) { | ||
input.observer.onNext(i); | ||
} | ||
} | ||
|
||
@GenerateMicroBenchmark | ||
public void observableConsumption(UseCaseInput input) throws InterruptedException { | ||
input.observable.subscribe(input.observer); | ||
input.awaitCompletion(); | ||
} | ||
|
||
@GenerateMicroBenchmark | ||
public void iterableViaForLoopConsumption(UseCaseInput input) throws InterruptedException { | ||
for (int i : input.iterable) { | ||
input.observer.onNext(i); | ||
} | ||
} | ||
|
||
@GenerateMicroBenchmark | ||
public void iterableViaHasNextConsumption(UseCaseInput input) throws InterruptedException { | ||
Iterator<Integer> iterator = input.iterable.iterator(); | ||
while (iterator.hasNext()) { | ||
input.observer.onNext(iterator.next()); | ||
} | ||
} | ||
} |
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