Skip to content

Commit

Permalink
Fix style and deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Sep 18, 2021
1 parent b5b1ad5 commit c8cbf1f
Show file tree
Hide file tree
Showing 184 changed files with 1,199 additions and 1,029 deletions.
6 changes: 3 additions & 3 deletions src/jmh/java/hu/akarnokd/atomics/QueueDrainAsync3Perf.java
Expand Up @@ -26,7 +26,7 @@ public void queueDrainAtomic1() {

for (;;) {
counter++;

missed = wip.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -45,7 +45,7 @@ public void queueDrainAtomic2() {

for (;;) {
counter++;

missed = w.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -64,7 +64,7 @@ public void queueDrainAtomic3() {

for (;;) {
counter++;

int u = w.get();
if (missed == u) {
missed = w.addAndGet(-missed);
Expand Down
6 changes: 3 additions & 3 deletions src/jmh/java/hu/akarnokd/atomics/QueueDrainAsyncPerf.java
Expand Up @@ -26,7 +26,7 @@ public void queueDrainAtomic1() {

for (;;) {
counter++;

missed = wip.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -45,7 +45,7 @@ public void queueDrainAtomic2() {

for (;;) {
counter++;

missed = w.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -64,7 +64,7 @@ public void queueDrainAtomic3() {

for (;;) {
counter++;

int u = w.get();
if (missed == u) {
missed = w.addAndGet(-missed);
Expand Down
6 changes: 3 additions & 3 deletions src/jmh/java/hu/akarnokd/atomics/QueueDrainPerf.java
Expand Up @@ -24,7 +24,7 @@ public void queueDrainAtomic1() {

for (;;) {
counter++;

missed = wip.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -41,7 +41,7 @@ public void queueDrainAtomic2() {

for (;;) {
counter++;

missed = w.addAndGet(-missed);
if (missed == 0) {
break;
Expand All @@ -58,7 +58,7 @@ public void queueDrainAtomic3() {

for (;;) {
counter++;

int u = w.get();
if (missed == u) {
missed = w.addAndGet(-missed);
Expand Down
8 changes: 4 additions & 4 deletions src/jmh/java/hu/akarnokd/atomics/TerminalAtomics.java
Expand Up @@ -13,11 +13,11 @@
@Fork(value = 1)
@State(Scope.Thread)
public class TerminalAtomics {

final AtomicReference<Object> ref = new AtomicReference<>();

final Object o = new Object();

void getGetAndSet(Blackhole bh) {
Object o = ref.get();
if (o != null) {
Expand All @@ -27,7 +27,7 @@ void getGetAndSet(Blackhole bh) {
}
}
}

void getAndSet(Blackhole bh) {
Object o = ref.getAndSet(null);
if (o != null) {
Expand Down
Expand Up @@ -10,7 +10,7 @@
import com.typesafe.config.*;

import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.*;
import akka.stream.javadsl.*;
import hu.akarnokd.reactive.comparison.consumers.PerfAsyncConsumer;
import io.reactivex.Flowable;
Expand All @@ -27,7 +27,7 @@ public class AkkaStreamsCrossMapPerf {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

Publisher<Integer> flatMapAkkaAkka;

Expand All @@ -54,7 +54,7 @@ public void setup() throws Exception {
Config cfg = ConfigFactory.parseResources(getClass(), "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);

materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

Integer[] outer = new Integer[count];
Arrays.fill(outer, 777);
Expand Down Expand Up @@ -210,7 +210,7 @@ public static void main(String[] args) {
Config cfg = ConfigFactory.parseResources(AkkaStreamsCrossMapPerf.class, "/akka-streams.conf").resolve();
ActorSystem actorSystem = ActorSystem.create("sys", cfg);

ActorMaterializer materializer = ActorMaterializer.create(actorSystem);
Materializer materializer = Materializer.createMaterializer(actorSystem);


Integer[] outer = new Integer[100];
Expand Down
Expand Up @@ -9,7 +9,7 @@
import com.typesafe.config.*;

import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.*;

@BenchmarkMode(Mode.Throughput)
Expand All @@ -27,7 +27,7 @@ public class AkkaStreamsFlatMapPerf {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

Publisher<Integer> akRangeFlatMapJust;

Expand All @@ -38,7 +38,7 @@ public void setup() throws Exception {
Config cfg = ConfigFactory.parseResources(AkkaStreamsFlatMapPerf.class, "/akka-streams.conf");
actorSystem = ActorSystem.create("sys", cfg);

materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

akRangeFlatMapJust = s ->
Source.range(1, times)
Expand Down
Expand Up @@ -10,7 +10,7 @@
import com.typesafe.config.*;

import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.*;
import akka.stream.javadsl.*;
import hu.akarnokd.reactive.comparison.consumers.PerfAsyncConsumer;
import reactor.core.publisher.Flux;
Expand All @@ -27,7 +27,7 @@ public class AkkaStreamsReactorCrossMapPerf {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

Publisher<Integer> flatMapAkkaAkka;

Expand All @@ -54,7 +54,7 @@ public void setup() throws Exception {
Config cfg = ConfigFactory.parseResources(AkkaStreamsReactorCrossMapPerf.class, "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);

materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

Integer[] outer = new Integer[count];
Arrays.fill(outer, 777);
Expand Down Expand Up @@ -210,7 +210,7 @@ public static void main(String[] args) {
Config cfg = ConfigFactory.parseResources(AkkaStreamsReactorCrossMapPerf.class, "/akka-streams.conf").resolve();
ActorSystem actorSystem = ActorSystem.create("sys", cfg);

ActorMaterializer materializer = ActorMaterializer.create(actorSystem);
Materializer materializer = Materializer.createMaterializer(actorSystem);


Integer[] outer = new Integer[100];
Expand Down
Expand Up @@ -43,14 +43,14 @@ public class MaterializationBenchmarkFanInOutPerf {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

@Setup
public void setup() {
Config cfg = ConfigFactory.parseResources(getClass(), "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);

materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

akka = RunnableGraph.fromGraph(GraphDSL.create(b -> {
Shape broadcast = b.add(new Broadcast(complexity, false));
Expand Down
6 changes: 3 additions & 3 deletions src/jmh/java/hu/akarnokd/comparison/ReactiveStreamsImpls.java
Expand Up @@ -24,7 +24,7 @@

import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.*;
import akka.stream.javadsl.*;
import io.reactivex.*;
import io.reactivex.Observable;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class ReactiveStreamsImpls {

ActorSystem actorSystem;

private ActorMaterializer materializer;
private Materializer materializer;

private List<Integer> values;

Expand Down Expand Up @@ -137,7 +137,7 @@ public void setup() throws Exception {
Config cfg = ConfigFactory.parseResources(ReactiveStreamsImpls.class, "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);

materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

akRange = s -> {
Source.range(1, times)
Expand Down
2 changes: 1 addition & 1 deletion src/jmh/java/hu/akarnokd/comparison/Util.java
Expand Up @@ -37,7 +37,7 @@ static Path findPath(String resourceName) {
return Paths.get("files", resourceName);
}
}

public static Set<String> readScrabbleWords() {
Set<String> scrabbleWords = new HashSet<>() ;
try (Stream<String> scrabbleWordsStream = Files.lines(findPath("ospd.txt"))) {
Expand Down
Expand Up @@ -21,35 +21,33 @@
import java.util.concurrent.*;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.*;

import com.typesafe.config.*;

import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.japi.function.Function;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.*;

/**
* Shakespeare with Akka-Stream Optimized.
*
*
* @author José
* @author akarnokd
*/
public class ShakespearePlaysScrabbleWithAkkaStreamBeta extends ShakespearePlaysScrabble {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

@Setup
public void setup() {

Config cfg = ConfigFactory.parseResources(ShakespearePlaysScrabbleWithAkkaStreamOpt.class, "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);
materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

}

Expand Down
Expand Up @@ -28,27 +28,27 @@
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.japi.function.Function;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.*;

/**
* Shakespeare with Akka-Stream Optimized.
*
*
* @author José
* @author akarnokd
*/
public class ShakespearePlaysScrabbleWithAkkaStreamOpt extends ShakespearePlaysScrabble {

ActorSystem actorSystem;

ActorMaterializer materializer;
Materializer materializer;

@Setup
public void setup() {

Config cfg = ConfigFactory.parseResources(ShakespearePlaysScrabbleWithAkkaStreamOpt.class, "/akka-streams.conf").resolve();
actorSystem = ActorSystem.create("sys", cfg);
materializer = ActorMaterializer.create(actorSystem);
materializer = Materializer.createMaterializer(actorSystem);

}

Expand Down
Expand Up @@ -44,7 +44,7 @@ public class ShakespearePlaysScrabbleWithDirect extends ShakespearePlaysScrabble
public List<Entry<Integer, List<String>>> measureThroughput() throws InterruptedException {

TreeMap<Integer, List<String>> treemap = new TreeMap<Integer, List<String>>(Comparator.reverseOrder());

for (String word : shakespeareWords) {
if (scrabbleWords.contains(word)) {
HashMap<Integer, MutableLong> wordHistogram = new LinkedHashMap<>();
Expand Down Expand Up @@ -91,12 +91,12 @@ public List<Entry<Integer, List<String>>> measureThroughput() throws Interrupted
for (int i = 3; i < word.length(); i++) {
max2 = Math.max(max2, letterScores[word.charAt(i) - 'a']);
}

sum2 += max2;
sum2 = 2 * sum2 + (word.length() == 7 ? 50 : 0);

Integer key = sum2;

List<String> list = treemap.get(key) ;
if (list == null) {
list = new ArrayList<>() ;
Expand All @@ -106,9 +106,9 @@ public List<Entry<Integer, List<String>>> measureThroughput() throws Interrupted
}
}
}

List<Entry<Integer, List<String>>> list = new ArrayList<Entry<Integer, List<String>>>();

int i = 4;
for (Entry<Integer, List<String>> e : treemap.entrySet()) {
if (--i == 0) {
Expand Down
Expand Up @@ -42,7 +42,7 @@ static Ix<Integer> chars(String word) {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(
iterations = 5, time = 1
iterations = 5, time = 1
)
@Measurement(
iterations = 5, time = 1
Expand Down
Expand Up @@ -45,7 +45,7 @@ static Flux<Integer> chars(String word) {

@Setup
public void localSetup() {
scheduler = Schedulers.newElastic("RcParallel");
scheduler = Schedulers.newBoundedElastic(10, 60, "RcParallel");
}

@TearDown
Expand Down

0 comments on commit c8cbf1f

Please sign in to comment.